This app is the default Hello World SAM template API running in Docker against localstack.
All commands are run using the awslocal and samlocal executables, such that calls will point at localhost (where localstack is running), instead of a real AWS location.
The API was generated by running the following on the api container:
# creates a directory with a name you provide, in my case "localstack-sam-example"
samlocal init Bring up the containers:
docker-compose up -dDeploy the app:
# create a shell session on the SAM container
docker-compose exec api sh -l
# cd into app directory (must run SAM CLI commands here)
cd localstack-sam-example
# creates/updates the .aws-sam directory with the built code
samlocal build
# deploys the code
samlocal deploy --config-file=samconfig.tomlWhen you deploy a new SAM build, it generates a new app ID, which is needed to make http calls. Run this command locally to see the new base URL
docker-compose exec aws sh -c "chmod 777 print_api_base_url.sh && ./print_api_base_url.sh"Once you know the base url, you can make requests to the API. The Hello World app comes with a single endpoint at /hello.
The resulting command should look something like this:
curl -x GET http://localhost:4566/restapis/0ve7vd2lsz/Prod/_user_request_/helloYou should see the following result:
{"message":"hello world"}