Skip to content

Latest commit

 

History

History

AWS_Codepipeline_Disable_Stage_Transition

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

AWS Health Issue Amazon Cloudwatch event trigger AWS CodePipeline Disable Stage Transition using AWS Lambda

Description

This sample highlights you can automatically stop a deployment when an Amazon EC2 issue occurs by disabling the stage transition in AWS Code Pipeline in response to an AWS Health Issue CloudWatch event.

Setup and Usage

Cloudformation Setup

Choose Launch Stack to launch the template in the US East (N. Virginia) Region in your account:

Launch AWS Health Code Pipeline Disable Stage Transition

Please update your region, CodePipeline name and Stage name according to your requirements.

Manual Setup

  1. Create an IAM role for the Lambda function to use. Attach the IAM policy to the role in the IAM console. Documentation on how to create an IAM policy is available here: http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html Documentation on how to create an IAM role for Lambda is available here: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html#roles-creatingrole-service-console

  2. Create a Lambda JavaScript function by using the sample provided and choose the IAM role created in step 1. Be sure to update the configuration of the Lambda function per your needs. More information about Lambda is available here: http://docs.aws.amazon.com/lambda/latest/dg/getting-started.html

  3. Create a CloudWatch Events rule to trigger the Lambda function created in step 2 matching an AWS Health Issue. An example of Cloudwatch rule event pattern for EC2 issues is here. Documentation on how to create an AWS Health CloudWatch Events rule is available here: http://docs.aws.amazon.com/health/latest/ug/cloudwatch-events-health.html

More information about AWS Health is available here: http://docs.aws.amazon.com/health/latest/ug/what-is-aws-health.html

Note that this is a just an example of how to set up automation with AWS Health, Amazon CloudWatch events, and AWS Lambda. We recommend testing the example and tailoring it to your environment before using it in your production environment.

Please also note that this will only capture EC2 issues that are generated by AWS Health as CloudWatch events.

License

AWS Health Tools are licensed under the Apache 2.0 License.