-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reference a DynamoDB table name and Elasticsearch domain endpoint in a Lambda function CF template? #2613
Comments
Currently we allow trigger/streaming functionality for S3 and DDB tables added using the |
Thank you for reply 👍. Regarding referencing the Elasticsearch endpoint/domain, I wanted to integrate geolocation search and as a result I followed the guidelines here: Thanks again for your help, I hope that explains better what is my use-case here. |
I think I did something similar. I have a graphQL API, and a REST API. The REST API uses a lambda function which amplify created. When I added the REST API, I answered a question saying I wanted the function to have access to the appsync stuff (not really understanding how this would work). Amplify created a cloudformation-template.json file for the new function, which had a section in it to provide the permissions for the lambda function. But it did not give permission to directly access the DynamoDB tables used in the graphQL API. So I added that manually in the new template, in the existing AmplifyResourcesPolicy section. I added a new section like this, copying the format of existing sections:
After amplify deploys the lambda function, I can go to the AWS Lambda console and see the permissions given to the function to verify it is what I intended. |
Thanks a lot for your time. Your suggestion above will work fine for DynamoDB, but not sure if the same pattern will apply as well for Elasticsearch resources. In addition to that, in my opinion this is still not the right approach as the CF stacks referencing a DynamoDB table in this way will know how its name is built. If the table name format changes in the future, then all the places referencing a DynamoDB table will have to be adjusted as well. |
@mrducky4 your work wouldn't perhaps be open source would it? I am looking to do similar. 😇 |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Which Category is your question related to?
In a Lambda function I would like to reference a DynamoDB table name and the Elasticsearch endpoint created as part of the API (GraphQL) stack. Preferably I would like those values to be provided as environment variables.
What AWS Services are you utilizing?
AppSync, Lambda, DynamoDB, Elasticsearch
Provide additional details e.g. code snippets
I created a new Lambda function by using the command
amplify add function
. The CloudFormation template generated by Amplify CLI for such a Lambda function includes a single Parameterenv
:How can I reference as well a DynamoDB table name created for the GraphQL/AppSync schema and the Elasticsearch domain endpoint created as a result of making the entity
@searchable
? Is there any documentation on how that could be accomplished?The text was updated successfully, but these errors were encountered: