Skip to content

Instantly share code, notes, and snippets.

@kevinkarwaski
Last active July 29, 2016 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinkarwaski/83a102406761b17ed00c291f4befbac5 to your computer and use it in GitHub Desktop.
Save kevinkarwaski/83a102406761b17ed00c291f4befbac5 to your computer and use it in GitHub Desktop.
"MyLambdaLifecycleFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "asg-graceful-lifecycle-termination.lambda_handler",
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Code": {
"S3Bucket": "lambda-functions",
"S3Key": "asg-graceful-lifecycle-termination.zip"
},
"Runtime": "python2.7",
"Timeout": "300"
}
}
"myLifecycleHookTopic" : {
"Type" : "AWS::SNS::Topic",
"Properties" : {
"Subscription" : [
{ "Endpoint" : { "Fn::GetAtt" : [ "MyLambdaLifecycleFunction", "Arn" ] }, "Protocol" : "lambda" }
]
}
}
"myLifecycleHook": {
"Type": "AWS::AutoScaling::LifecycleHook",
"Properties": {
"AutoScalingGroupName": { "Ref": "myAutoScalingGroup" },
"HeartbeatTimeout": 300,
"LifecycleTransition": "autoscaling:EC2_INSTANCE_TERMINATING",
"NotificationMetadata": { "Ref": "StackName" },
"NotificationTargetARN": { "Ref": "myLifecycleHookTopic" },
"RoleARN": { "Fn::GetAtt": [ "lifecycleHookRole", "Arn" ] }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment