This service is an example implementation how to use AWS CloudWatch events to monitor ECS container states. AWS CloudWatch event triggers a Lambda function that published a message to an SNS topic, which can be subscribed to send, e.g. message to an email address, SMS message, or notification to Slack channel.
Subscribe to AWS ECS Event Stream Using Serverless Framework @ Medium
This service uses Serverless Framework to deploy components to AWS.
To install service use sls install -u https://github.com/maasglobal/ecs-event-notifications -n my-ecs-events
, where my-ecs-events
is the name of the service you prefer to use.
After installation, change directory to my-ecs-events
and install dependencies with npm install
.
When you are ready, you can deploy the service with sls deploy
.
By default, this service will not create a subscription to SNS topic, but you can add the subscription, by using CloudFormation, AWS CLI or web console.
To use CloudFormation to subscribe notifications to your email, add following snippet to resources block of the serverless.yml.
ECSStateChangeSubscription:
Type: AWS::SNS::Subscription
Properties:
Endpoint: [email protected]
Protocol: email
TopicArn:
Ref: ECSStateChangeTopic
After deployment, you should have subscription confirmation email titled "AWS Notification - Subscription Confirmation" in your inbox, then follow the instructions on email.
More info about how to configure the CloudWatch event trigger for ECS Serverless Docs and AWS docs