Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 1.51 KB

readme.md

File metadata and controls

38 lines (32 loc) · 1.51 KB

API Gateway + Dynamodb

apigateway_dynamodb.drawio.svg

🧪 Testing it with Gitpod

Open in Gitpod

🧪 Testing it without Gitpod

1. 📝 Preparation

  • Follow installations
  • Choose Localstack hosting and follow the different steps
  • You can also choose Cloud hosting and use terraform instead of tflocal

2. 🏃 Running

You can follow this steps or directly launch the script ./bin/run.sh

Now that your infrastructure is deployed on LocalStack, test its functionality by:

  • Recovering the API key from terraform output
API_KEY=$(tflocal output -json | jq -r .apigw_key.value)
  • Recovering the API id
REST_API=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r '.items[0].id')
  • Inserting data in DynamoDB via API:
curl $REST_API.execute-api.localhost.localstack.cloud:4566/v1/pets -H "x-api-key: ${API_KEY}" -H 'Content-Type: application/json' --request POST --data-raw '{ "PetType": "dog", "PetName": "tito", "PetPrice": 250 }'
  • Requesting the inserted data
curl -H "x-api-key: ${API_KEY}" --request GET $REST_API.execute-api.localhost.localstack.cloud:4566/v1/pets/dog

3. 🚿 Cleaning up

tflocal destroy --auto-approve