|
2 | 2 |
|
3 | 3 | The SAM template deploys a API Gateway REST API with Lambda function integration, an SNS topic and the IAM permissions required to run the application. Whenever the REST API is invoked, the Lambda function publishes a message to the SNS topic. The AWS SAM template deploys the resources and the IAM permissions required to run the application. |
4 | 4 |
|
| 5 | +## Features |
| 6 | + |
| 7 | +- **API Gateway REST API** with Lambda integration |
| 8 | +- **Lambda function** that publishes messages to SNS |
| 9 | +- **SNS topic** for message publishing |
| 10 | +- **CloudWatch Alarm** monitoring API errors |
| 11 | +- **Amazon CloudWatch Synthetics Canary** for automated API endpoint monitoring |
| 12 | +- **AWS X-Ray tracing** enabled for distributed tracing on LAmbda and APIGW (incurs additional costs) |
| 13 | +- **S3 bucket** for Synthetics artifacts storage |
| 14 | + |
5 | 15 | Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/apigw-lambda-sns/. |
6 | 16 |
|
7 | | -Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example. |
| 17 | +Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. **Note: AWS X-Ray tracing is enabled which incurs additional charges based on traces recorded and retrieved.** You are responsible for any AWS costs incurred. No warranty is implied in this example. |
8 | 18 |
|
9 | 19 | ## Requirements |
10 | 20 |
|
11 | | - |
12 | 21 | * [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. |
13 | 22 | * [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured |
14 | 23 | * [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
@@ -50,19 +59,27 @@ curl --location --request GET 'https://<api_id>.execute-api.<region>.amazonaws.c |
50 | 59 | ``` |
51 | 60 | In order to receive a notification, please make sure to configure subscription in the SNS topic. |
52 | 61 |
|
| 62 | +### Additional Features |
53 | 63 |
|
54 | | -## Cleanup |
| 64 | +- **CloudWatch Alarm**: Monitor the Synthetics Canary failures. The alarm triggers when the canary fails at least once within a 5-minute period. |
| 65 | +- **Synthetics Canary**: Automatically tests the API endpoint every minute to ensure availability. If you want to alarm on this, you must manually create a CloudWatch Alarm or update the template |
| 66 | +- **X-Ray Tracing**: Distributed tracing is enabled for both API Gateway and Lambda to help with debugging and performance analysis. |
55 | 67 |
|
56 | 68 |
|
| 69 | +## Cleanup |
| 70 | +
|
57 | 71 | 1. Delete the stack |
58 | 72 | ``` |
59 | 73 | aws cloudformation delete-stack —stack-name STACK_NAME |
60 | 74 | ``` |
61 | | -2. Confirm the stack has been deleted |
| 75 | +2. **Manually delete the S3 bucket** - The Synthetics artifacts bucket must be manually emptied and deleted after stack deletion |
| 76 | +3. Confirm the stack has been deleted |
62 | 77 | ``` |
63 | 78 | aws cloudformation list-stacks —query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus" |
64 | 79 | ``` |
65 | 80 |
|
| 81 | +**Important**: You must manually delete the S3 bucket created for Synthetics artifacts after deleting the CloudFormation stack, as it will contain canary run artifacts. |
| 82 | +
|
66 | 83 | ---- |
67 | 84 | Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
68 | 85 |
|
|
0 commit comments