-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
aws-dynamodb: misreporting deployed table name when testing lambda function locally with sam #28824
Comments
Looks like it only happens on SAM running localhost but actually it's correct when you deploy? |
Yep. |
I can reproduce this issue and can confirm that it only happens on |
With a bit more investigation, I don't believe this issue is related to CDK. Going to close this issue. Feel free to cut an issue to Here is what I tried and came to conclusion that this is not related to CDK. I first followed your reproduction step and created a CDK app. I then used the synthesized template (removed all CDK related metadata and fields) using AWS SAM CLI. I built and deploy the YAML template using AWS SAM CLI. At this point, the template is basically a SAM template and has nothing to do with CDK. I am able to successfully deploy the template. I can then reproduce the same issue as described where running
While if I invoke the function from AWS Console, it gives the correct table name and arn. AppendixHere's the YAML template file I used
|
Closing this issue as this is unrelated to CDK. |
|
Describe the bug
When testing locally with SAM a TableV2's name property, when put into a NodeJsFunction's environment, is set incorrectly. The name matches the name in the synthesized template.json file, but does not match the actual deployed name of the table.
It is set correctly in the environment of the deployed lambda, but it hurts development speed to have to deploy before testing a lambda function
Expected Behavior
The name property of the TableV2 object should return the deployed name of the table, even when testing locally.
Current Behavior
environment variables are only set properly in the deployed lambda functions,
Reproduction Steps
run
cdk init app --language typescript
add the
@types/aws-lambda
packagelib/test.ts:
constructor of the stack class in lib/(dirname}-stack.ts:
run
cdk deploy
run
sam local invoke -t cdk.out/{stack-name}.template.json
to get the output:Querying the deployed API endpoint gives (which is the correct info):
Possible Solution
No response
Additional Information/Context
sam --version:
SAM CLI, version 1.107.0
I'm using nvm to set my node version, the default installed version is
v21.6.0
but all commands were run afternvm use 20
, so unless there's something wrong with nvm it shouldn't matterCDK CLI Version
2.122.0 (build 7e77e02)
Framework Version
No response
Node.js Version
v20.11.0
OS
Ubuntu 22.04.3 LTS
Language
TypeScript
Language Version
TypeScript 5.3.3
Other information
No response
The text was updated successfully, but these errors were encountered: