- Follow installations
- Choose Localstack hosting and follow the different steps
- You can also choose Cloud hosting and use
terraform
instead oftflocal
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
tflocal destroy --auto-approve