terraform-aws-ec2-instance icon indicating copy to clipboard operation
terraform-aws-ec2-instance copied to clipboard

Add support for `user_data_replace_on_change` field

Open nk9 opened this issue 3 years ago • 0 comments

Describe the Bug

The aws provider changed behavior in version 4. Previously, changes to the user_data field of an ec2 instance caused the instance to be torn down and recreated. Now, the user_data will be updated but the instance won't be recreatead. This means that, in most cases, the user_data script will not be run until the user somehow manually recreates the instance. If the user knows what's going on, they might choose to mark the instance for recreation using taint before or -replace on apply.

The change is discussed here and the field user_data_replace_on_change was added to aws_instance to provide the old behavior for those who wanted it.

Expected Behavior

I'd expect to be able to use this new field to continue having the longstanding behavior when the user_data is changed.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create an instance using user_data or user_data_base64
  2. Apply the change so the instance shows up
  3. Change the user_data
  4. Re-apply
  5. Notice that the instance has not been recreated.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

$ terraform version
Terraform v1.2.5
on darwin_arm64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/aws v4.23.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/local v2.2.3
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/random v3.3.2
+ provider registry.terraform.io/hashicorp/tls v4.0.0

nk9 avatar Jul 25 '22 15:07 nk9