This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.
- src/accounts-service - A mock set of Lambdas & Service for creating and retreiving customer accounts (refer to
template-swagger.yaml
for api descriptions). - src/authorizer-service - A custom Authorizer function for authenticating calls to the customer account service
- template-sam.yaml - A template that defines the application's AWS resources.
- template-swagger.yaml - A swagger template that defines the API
- SAM CLI - Install SAM
- Docker - Install Docker
Note: PITA - SAM local does not currently support custom authorizer run locally
sam build -t template-sam.yaml
sam local start-api
To build and deploy your application to AWS (requires valid AWS account and tokens):
sam build
sam deploy --guided
To delete the sample application that you created, use the AWS CLI. Assuming you used customer-account-service
for the stack name, you can run the following:
aws cloudformation delete-stack --stack-name customer-account-service
- Example
GET
request to/api/customer-account/v1/accounts/{accountId}
Requires aBearer
token with value ofletmein
otherwise will deny a user access.
curl --location --request GET 'https://<api-gateway-endpoint>/api/customer-account/v1/accounts/12345' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer letmein' \
--data-raw ''
- Example
POST
request to/api/customer-account/v1/accounts
curl --location --request POST 'https://<api-gateway-endpoint>/api/customer-account/v1/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
"accountName": "my test account"
}'
See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
See the Custom Authorizer Flow for details on how custom authorization works.