Open garydeng01 opened 1 year ago
My guess is that your local invoke works because you're running it on the nested stack, and so the parameter override happens in that stack. Since you run the local start-api on the parent stack, it's probably trying to override the parameter on this parent stack and not on the nested stack. If this is the case, not sure if we're able to pass down parameter overrides onto nested stacks. Let me try to look into this further.
Yes. I would agree with your assessment that it seems to do with the parameter override having difficulty with a stack that is nested relative to the stack/template that is passed in to SAM CLI as the -t parameter.
Thanks @giterdoneh for raising this issue. This is not an issue, but a feature request, SAM CLI currently does not support processing the resources that are connected to resources defined in other stacks or nested stacks. I will share this issue with our PM to see if we can prioritize this issue or not.
To explain why sam local invoke
works on the nested stack, but it will not work on the main stack. The issue is the parameter you are overriding is defined only in the nested stack but not in the main stack, so SAM CLI was able to set the value of it when the nested stack was used.
Description:
I am getting an error when trying to use 'sam local start-api' on a template containing the API Gateway and generated by 'cdk synth'. The API Gateway is in the main stack. The lambda function is in a nested stack. The lambda function has a layer that is also in a nested stack (parallel to the lambda function stack). The ARN for the lambda layer in the AWS account is being passed as a --parameter-override.
However, I am having success running 'sam local invoke' and specifying the nested stack template with the lambda function.
Here is the CDK code for the stacks:
Steps to reproduce:
In contrast, 'sam local invoke' on the nested stack with the lambda function will work:
Observed result:
Expected result:
An HTTP response with status 200
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.65.0Add --debug flag to command you are running