Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An Ec2 Alarm that when triggered will create an SSM OpsItem #496

Open
1 of 2 tasks
alekasw opened this issue Sep 4, 2021 · 1 comment
Open
1 of 2 tasks

An Ec2 Alarm that when triggered will create an SSM OpsItem #496

alekasw opened this issue Sep 4, 2021 · 1 comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. language/python Related to Python examples p2

Comments

@alekasw
Copy link
Contributor

alekasw commented Sep 4, 2021

🚀 Feature Request

General Information

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

Description

This example shows how you can use the cdk to automate attaching an alarm to an ec2 instance at launch time, then when the alarm is triggered how it can create an systems manager opsitem with an associated run book.

Proposed Solution

Koi-Demo-Architecture

The workflow of this solution is as follows: When an EC2 instance is launched it will trigger an Eventbridge rule that kicks off a lambda function. The lambda function determines if the EC2 instance already has a matching alarm. If it does not then it will create and attach a "StatusCheckFailed" metric alarm and tag the instance so next time it is launched it will skip the Alarm creation logic.

The solution also deploys an SSM automation run command document that can be used to easily trigger the alarm via a bash
shell script that executes the set-alarm-state aws cli command.

Once the alarm is triggered another Eventbridge rule will kick-off the second lambda function that creates an SSM OpsItem with an associated runbook.

Clean-up: cdk destroy then delete any Alarms that were created

Environment

  • CDK CLI Version: 1.121.0
  • Example: Automate EC2 alarm creation that triggers an OpsItem when in "ALARM" state
  • Example Version: 1.0
  • OS: Amazon Linux 2
  • Language: Python

Other information

The cdk stack deploys the following resources:

  • IAM Policies and Roles
  • IAM Instance Profile
  • EC2 Instance
  • SNS Topic and Subscription
  • Lambda Functions (Two)
  • Eventbridge Rules (Two)
  • SSM Document
@alekasw alekasw added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 4, 2021
@ryparker ryparker added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 28, 2021
@ryparker
Copy link
Contributor

ryparker commented Sep 28, 2021

Hey @alekasw 👋🏻

Thanks for opening this feature request.

Marking this as p2 which means that we are unable to work on this immediately. We use +1s to help us prioritize our work, and as always we are happy to take contributions if anyone is interested to pick this up and submit a PR (please make sure to follow our contribution guidelines.) 🙏

@ryparker ryparker added the language/python Related to Python examples label Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. language/python Related to Python examples p2
Projects
None yet
Development

No branches or pull requests

2 participants