-
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
Where should I add my custom resolver CloudFormation config? #1002
Comments
@kstro21 Thanks for the comment. You are able to add the resource to any stack in the stacks directory of the API project's stacks directory. You may add it at |
https://aws-amplify.github.io/docs/cli/graphql#api-category-project-structure basically describes this structure, but it would be very useful if the documentation at https://aws-amplify.github.io/docs/cli/graphql#add-a-custom-resolver-that-targets-an-aws-lambda-function referenced the first link. |
Thanks, @mikeparisstuff I've tested both approaches and works. |
Additionally, https://aws-amplify.github.io/docs/cli/graphql#add-a-custom-resolver-that-targets-an-aws-lambda-function is somewhat misleading / incomplete. Firstly, the Additionally, as noted in aws-amplify/amplify-category-api#440, since the cloudformation stacks are named so arbitrarily, getting the
but it's very much not ideal. |
@zjullion You should be able to reference the ApiId directly from the stacks paramters. Here is an example: The parameter definition that you can add to your template: Example usage of the parameter: |
@mikeparisstuff but that only will work for templates inside |
@mikeparisstuff thank you for that, it's much cleaner and simpler than what I was doing. Obviously, the |
@zjullion yes, it's much cleaner and simpler for any stacks we create under But then, if you want to create a new env, it becomes really hard to maintain. See the point? It would be really nice to have aws-amplify/amplify-category-api#440 but I started to note another issue, the order in which the stacks are created/updated is a mess. aws-amplify/amplify-category-api#440 will also require that some CC: @mikeparisstuff |
@mikeparisstuff Just out of curiosity these CFN templates have to be json or can they be written in YAML? |
I'm also confused how to get I'm trying to set it as lambda environment variable so I can use it to call the correct dynamodb table which uses this value to suffix the table name. Is there another way to get this value currently? Please let me know, I'm stuck. |
@cocacrave Yes, if you define the parameter in your stack it will be passed down. See https://github.com/mikeparisstuff/amplify-cli-nested-api-sample/blob/7c4c7dec85b4f27e8344bea6063b4d85cf48771f/amplify/backend/api/amplifynestedsample/stacks/CustomResources.json#L5 for an example. The Amplify API category will automatically wire up your custom stacks to get this param when specified. |
I agree that the docs for adding a custom resolver should include a link to https://aws-amplify.github.io/docs/cli-toolchain/graphql#api-category-project-structure . In fact, I really wish I had read about the API Category Project Structure a long time ago. Until I read that section, I had no understanding of what |
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 |
I'm following the steps here https://aws-amplify.github.io/docs/cli/graphql#add-a-custom-resolver-that-targets-an-aws-lambda-function but in the steps that says: Add the function as an AppSync data source in the stack’s Resources block.. Ok, but, and the template? which one? amplify\backend\api\myapi\stacks\CustomResources.json or should I add a new one in _amplify\backend\api\myapi\stacks_? Obviously, it is not in the Lambda's template because of the parameters
S3DeploymentBucket
andS3DeploymentRootKey
are not injected/passed to the Lambda's template, right?I think the documentation is not clear about the process and should be updated accordingly.
The text was updated successfully, but these errors were encountered: