1

I use AWS CDK for setting my stack and deploying, it all works fine when testing with the remote API endpoints.

However, to be able to run and test it locally with SAM I generated a template for it using the cdk synth by running this command

cdk synth --no-staging MyLambdaAPIStack > .local/template.yml --profile [AWS_CONFIG_PROFILE]

Using the generated template I'm able to start the API locally with the SAM command below

$ sam local start-api -t .local/template.yml --profile [AWS_CONFIG_PROFILE]

This starts the app on http://127.0.0.1:3000/

Testing my endpoint locally I get the error below

"message": "Requested resource not found",
"code": "ResourceNotFoundException",

PLEASE NOTE:

I understand I can also start a local DynamoDB with Docker but that requires me to manually recreate the tables and populate them with data

I'm looking for a solution that will enable me to use the remote DynamoDB OR dynamically create my tables using my existing stack template.

Any potential suggestion is appreciated.

fortunee
  • 3,852
  • 2
  • 17
  • 29
  • 1
    I don't know much about SAM or CDK.. maybe you already know it, but `localstack` is a good tool for local dev. You can just run `pip install aws-sam-cli-local` and `samlocal deploy` and your SAM will be deployed to `localstack`. Anyway, have you checked if the region is set up in your local profile? It is mandatory for dynamo clients IIRC. – Juan Fontes Dec 16 '21 at 04:40
  • @JuanFontes Thanks for your suggestion. Yes, I do have the region setup – fortunee Dec 16 '21 at 08:45

0 Answers0