Every time I create a new container on AWS ECS, I want the PublicIp
sent as a
message to my telegram channel.
+———-+ +—+ +——+ +——–+ |Cloudwatch+->+SNS+->+Lambda+->+Telegram| +———-+ +—+ +——+ +——–+
We are going to use this service to trigger our Lambda function. We need to make this first as our Cloudwatch monitoring event requires it to be defined.
Topics -> Create topic -> Name: toTelegram
That’s it, we don’t need to configure anything else.
I’ve never really used Cloudwatch before to monitor stuff, but I knew that I’d need to use it in order to detect a change in my infrastructure. It would be the trigger that starts the entire process
Events -> Rules -> Create Rule:
For Event Source, select Event Pattern and add the following code:
{
"source": [
"aws.ecs"
],
"detail-type": [
"ECS Task State Change"
],
"detail": {
"lastStatus": [
"RUNNING"
]
}
}
For Targets, select SNS topic, and then the topic that was created previously, toTelegram.
This is where the meat of what we’re trying to do
tags: aws, cloudwatch, sns, lambda