Skip to content

Commit

Permalink
ref(aws): Ensure CloudFormation does not replace running instances on…
Browse files Browse the repository at this point in the history
… AMI changes.

Use Stack Policy to prevent updated AMIs from CoreOS causing instance replacements.
When running update-aws-cluster.sh and the CoreOS version has been bumped then a
running machines will be replaced due to CF default behaviour

The Stack Policy is automatically applied on create and update
  • Loading branch information
helgi committed Sep 24, 2015
1 parent 46a5ec7 commit eb9e68c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/aws/provision-aws-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ aws cloudformation create-stack \
--template-body "$($THIS_DIR/gen-json.py --channel $COREOS_CHANNEL --version $COREOS_VERSION)" \
--stack-name $STACK_NAME \
--parameters "$(<$THIS_DIR/cloudformation.json)" \
--stack-policy-body "$(<$THIS_DIR/stack_policy.json)" \
$EXTRA_AWS_CLI_ARGS

# loop until the instances are created
Expand Down
21 changes: 21 additions & 0 deletions contrib/aws/stack_policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Statement" : [
{
"Effect" : "Deny",
"Principal" : "*",
"Action" : "Update:Replace",
"Resource" : "*",
"Condition" : {
"StringEquals" : {
"ResourceType" : ["AWS::EC2::Instance"]
}
}
},
{
"Effect" : "Allow",
"Principal" : "*",
"Action" : "Update:*",
"Resource" : "*"
}
]
}
1 change: 1 addition & 0 deletions contrib/aws/update-aws-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ aws cloudformation update-stack \
--template-body "$($THIS_DIR/gen-json.py --channel $COREOS_CHANNEL --version $COREOS_VERSION)" \
--stack-name $NAME \
--parameters "$(<$THIS_DIR/cloudformation.json)" \
--stack-policy-body "$(<$THIS_DIR/stack_policy.json)" \
$EXTRA_AWS_CLI_ARGS

echo_green "Your Deis cluster on AWS CloudFormation has been successfully updated."

0 comments on commit eb9e68c

Please sign in to comment.