@@ -49,45 +49,46 @@ npm run lint && npm run test
4949
50501 . Download and run docker image of dynamodb-local
5151
52- ``` shell
53- docker pull amazon/dynamodb-local
54- docker run -p 8000:8000 amazon/dynamodb-local
55- ```
52+ ``` shell
53+ docker pull amazon/dynamodb-local
54+ docker run -p 8000:8000 amazon/dynamodb-local
55+ ```
5656
57572. Create dynamodb-local tables - review the template.yaml because the ID is going to change
5858
59- ``` shell
60- aws dynamodb create-table --table-name bloginfrastructuresubscriptiondbF44CF6DE --attribute-definitions AttributeName=email,AttributeType=S --key-schema AttributeName=email,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000
61- aws dynamodb create-table --table-name bloginfrastructurecontactdbA1E13C61 --attribute-definitions AttributeName=name,AttributeType=S --key-schema AttributeName=name,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000
62- ```
59+ ` ` ` shell
60+ aws dynamodb create-table --table-name bloginfrastructuresubscriptiondbF44CF6DE --attribute-definitions AttributeName=email,AttributeType=S --key-schema AttributeName=email,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000
61+ aws dynamodb create-table --table-name bloginfrastructurecontactdbA1E13C61 --attribute-definitions AttributeName=name,AttributeType=S --key-schema AttributeName=name,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000
62+ ` ` `
6363
64643. Update lambda code to change the endpoint:
6565
66- ``` shell
67- const dbClient = process.env.AWS_SAM_LOCAL ? new DynamoDBClient({ endpoint: ' http://docker.for.mac.localhost:8000/' , }) : new DynamoDBClient ();
68- ```
66+ ` ` ` shell
67+ const dbClient = process.env.AWS_SAM_LOCAL ? new DynamoDBClient({ endpoint: ' http://docker.for.mac.localhost:8000/' , }) : new DynamoDBClient ();
68+ ` ` `
6969
70704. Generate the YAML file that SAM needs
7171
72- ``` shell
73- cdk synth blog-backend-infrastructure --no-staging > template.yml
74- ```
72+ ` ` ` shell
73+ cdk synth blog-backend-infrastructure --no-staging > template.yml
74+ ` ` `
7575
76765. Run SAM tests
7777
78- ``` shell
79- sam local invoke blog-backend-infrastructure-contact-lbd -e tests/events/contact.json
80- sam local invoke blog-backend-infrastructure-subscription-lbd -e tests/events/subscription.json
81- ```
78+ ` ` ` shell
79+ sam local invoke blog-backend-infrastructure-contact-lbd -e tests/events/contact.json
80+ sam local invoke blog-backend-infrastructure-subscription-lbd -e tests/events/subscription.json
81+ ` ` `
8282
83836. Review database records
8484
85- ``` shell
86- aws dynamodb scan --table-name bloginfrastructuresubscriptiondbF44CF6DE --endpoint-url http://localhost:8000
87- aws dynamodb scan --table-name bloginfrastructurecontactdbA1E13C61 --endpoint-url http://localhost:8000
88- ```
85+ ` ` ` shell
86+ aws dynamodb scan --table-name bloginfrastructuresubscriptiondbF44CF6DE --endpoint-url http://localhost:8000
87+ aws dynamodb scan --table-name bloginfrastructurecontactdbA1E13C61 --endpoint-url http://localhost:8000
88+ ` ` `
89+
90+ # ## Additional links
8991
90- ### Additional links
9192- How to create infrastructure with CDK [here](https://www.playingaws.com/posts/how-to-create-infrastructure-with-cdk/).
9293- How to add CI/CD to my CDK project [here](https://www.playingaws.com/posts/how-to-add-ci-cd-to-my-cdk-project/).
9394- How to create serverless applications with CDK and SAM [here](https://www.playingaws.com/posts/how-to-create-serverless-applications-with-cdk-and-sam/)
0 commit comments