Description
Environment information
System:
OS: macOS 14.5
CPU: (8) x64 Apple M2
Memory: 32.73 MB / 16.00 GB
Shell: Unknown
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
Yarn: undefined - undefined
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
pnpm: 8.15.4 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
NPM Packages:
@aws-amplify/backend: 1.0.4
@aws-amplify/backend-cli: 1.1.0
aws-amplify: 6.3.8
aws-cdk: 2.147.3
aws-cdk-lib: 2.147.3
typescript: 5.5.3
AWS environment variables:
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Description
Is it possible for a Function to receive the Endpoint of Data,
or the name and ARN of Datasources like DynamoDB?
For example, with Storage, you can use the "access" property in the defineStorage function to grant read and write permissions to a Function.
https://docs.amplify.aws/react/build-a-backend/functions/grant-access-to-other-resources/
However, a similar approach cannot be used with defineData as it's not possible to specify properties.
It is possible to directly set values for an already created function in backend.ts using CDK, but
if you're also using defineFunction for resolvers against Data,
I think an error would occur due to circular reference, as the reference order would be resolverFunction → Data → thisFunction.
const l1CloneFunction = backend.cloneFunction.resources.lambda.node
.defaultChild as CfnFunction;
l1CloneFunction.addPropertyOverride(
"Environment.Variables.TARGET_USER_TABLE",
backend.data.resources.tables.User.tableName ?? "",
);
Is there a good solution?