Created
June 26, 2021 08:40
-
-
Save nivleshc/40d3ef58a71b6a8d6be4864d67a9dbed to your computer and use it in GitHub Desktop.
This AWS SAM template is part of notify-on-running-ec2-instances. The template provisions all the required AWS resources.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: SAM template - send notifications for running ec2 instances | |
Parameters: | |
SlackWebhookURL: | |
Type: String | |
Description: Slack webhook url for sending notifications | |
Resources: | |
monitorEC2InstancesFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Description: This function will monitor all EC2 instances on a schedule and send a slack notification when any are found running. | |
Handler: src/monitor-ec2-instances.lambda_handler | |
Runtime: python3.7 | |
Timeout: 300 | |
Events: | |
CloudWatchEventsSchedule: | |
Type: Schedule | |
Properties: | |
Schedule: "cron(0 18 * * ? *)" | |
Name: CheckForRunningEC2Instances | |
Description: Check for running ec2 instances | |
Enabled: True | |
Policies: | |
- AWSLambdaBasicExecutionRole | |
- EC2DescribePolicy: {} | |
Environment: | |
Variables: | |
SLACK_WEBHOOK_URL: !Ref SlackWebhookURL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment