Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Commit

Permalink
Ignore AMI updates on etcd/master nodes, and disallow destroying etcd…
Browse files Browse the repository at this point in the history
… nodes resource

Currently if a new version of CoreOS comes out on a user's configured
channel after they've already deployed, and they re-run terraform apply,
Terraform will detect the new AMI, and when reconciling desired state,
it will attempt to destroy existing nodes to update the AMI.

In order to avoid this, I added a prevent_destroy hook to the etcd
nodes resource. I also added a ignore_changes to both the etcd node
resource, and the master launch configuration resource, to avoid
updating masters/etcd nodes if the AMI changes.

Longer term, I would expect the Container Linux Update Operator, or a
terraform operator could resolve this, but this seems like a reasonable
change to prevent accidental destruction of a cluster.
  • Loading branch information
Chance Zibolski committed Apr 25, 2017
1 parent cbe1d2c commit a40b4b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/aws/etcd/nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ resource "aws_instance" "etcd_node" {
user_data = "${ignition_config.etcd.*.rendered[count.index]}"
vpc_security_group_ids = ["${var.sg_ids}"]

lifecycle {
prevent_destroy = true
ignore_changes = ["ami"]
}

tags = "${merge(map(
"Name", "${var.cluster_name}-etcd-${count.index}",
"KubernetesCluster", "${var.cluster_name}"
Expand Down
2 changes: 2 additions & 0 deletions modules/aws/master-asg/master.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ resource "aws_launch_configuration" "master_conf" {
associate_public_ip_address = "${var.public_vpc}"
user_data = "${var.user_data}"


lifecycle {
create_before_destroy = true
ignore_changes = ["image_id"]
}

root_block_device {
Expand Down

0 comments on commit a40b4b4

Please sign in to comment.