Closed sisygoboom closed 1 month ago
Hey @sisygoboom, thank you for reaching out.
From the error message and behavior observed on the backend.ts
, the issue appears to similar to
https://github.com/aws-amplify/amplify-backend/issues/1375
https://github.com/aws-amplify/amplify-backend/issues/1552
Could you try the suggestions on comments https://github.com/aws-amplify/amplify-backend/issues/1375#issuecomment-2079388509 https://github.com/aws-amplify/amplify-backend/issues/1552#issuecomment-2138816880
You should be able to access the table name on the backend.ts
for example backend.data.resources.tables["Todo"].tableArn
which should return a token and resolved by CloudFormation.
Do let us know if i may have misunderstood anything.
But i do agree, a prop to add datasources on the function would be great. Marking this as feature request.
Environment information
Description
Amplify's backend currently makes anything outside of the expected patterns extremely difficult. This is because of a combination of two things: 1) Automated resource creation 2) Inability to access the low-level CDK constructs from said resource creation in a typesafe or object-oriented way with the ARNs attached
Example/steps to reproduce:
I have a custom resolver in my schema, it needs a role with access to write to DynamoDB.
I can see the problem from the console and its an easy fix:
but
defineFunction
does not allow me to modify any of the constructs. Next logical step would be to add a dynamodbdatasource to the handler but that is also not an option becausea.handler.function
only has the propertybrandSymbol
and no additional parameters besides the function. Next bet is to trya.query()...authorization(allow => ['dynamodb:Query'])
or something similar but that allow only includes IAM options. Event thedefineData
factory returns nothing of use.After exhausting options in
data/resource.ts
I looked for possibilities inbackend.ts
but unfortunately this turned out to be impossible without running into a circular dependency. It also doesn't help that while the cloudformation outputs are present somewhere in backend its not easy to navigate as the typing system here is very loose and the random hash applied to resources by amplify make it impossible to guess/hardcode the arn.// backend.ts
// data/resource.ts