Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

[first cut] update rollback failed lambda #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aarthykc
Copy link

@aarthykc aarthykc commented Nov 9, 2016

There are times when stacks are caught inUPDATE_ROLLBACK_FAILED and it's good to be alerted when a stack is in such a state. Since there are no cloudwatch events that currently track this, the easiest way was to create a lambda function that would do that looks at which productions are currently in the UPDATE_ROLLBACK_FAILED state and alert in case that is the case.
I'm currently testing for whether the stack is in UPDATE_COMPLETE to see if it sends a notification will change this back to UPDATE_ROLLBACK_FAILED when I confirm this works.

cc @ianshward, @emilymcafee - does this look okay ?

Next actions:

  • Create staging stack
  • test 😅

@aarthykc
Copy link
Author

aarthykc commented Nov 9, 2016

Apologies for the linting errors, looks like I didn't have that set up ! Will push changes with the right liniting.

Copy link
Member

@ianshward ianshward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarthykc I left some comments in this review. Looks like you're nearly there, but there are a few things that need to be changed.

I will look at the tests separately.

name: 'updateRollbackFailed',
sourcePath: 'rules/updateRollbackFailed.js',
parameters: {
includeResources: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this parameter be called otherStacks ? @aarthykc do you think this would be more intuitive?

{
Effect: 'Allow',
Action: [
'cloudformation:*'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarthykc this should be more specific, so that it adheres to least privilege. ie. i think this only needs to be cloudformation:DescribeStacks

if (err) return callback(err);
else {
data[0].forEach(function(i) {
if(i.name.indexOf('production') > -1 && i.status.indexOf('UPDATE_COMPLETE') > -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarthykc if I am reading this correctly, this will also catch stacks that are in any of these other status states shown in the list under Stack Status Codes here http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html

Is there a reason not to check for the exact match of UPDATE_ROLLBACK_FAILED?


function describeStacks(params, callback) {
var q1 = queue(1);
var cloudformation = new AWS.CloudFormation({region: 'us-east-1'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarthykc right now this just checks stacks in us-east-1. It should check for this state on stacks in all regions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants