-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource/aws_launch_configuration: Add support for ebs_block_device.*.no_device #4070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed acceptance testing but I do have a question why the one set hash required updating.
10 tests passed (all tests)
=== RUN TestAccAWSLaunchConfiguration_withSpotPrice
--- PASS: TestAccAWSLaunchConfiguration_withSpotPrice (8.94s)
=== RUN TestAccAWSLaunchConfiguration_withEncryption
--- PASS: TestAccAWSLaunchConfiguration_withEncryption (11.63s)
=== RUN TestAccAWSLaunchConfiguration_basic
--- PASS: TestAccAWSLaunchConfiguration_basic (17.03s)
=== RUN TestAccAWSLaunchConfiguration_withBlockDevices
--- PASS: TestAccAWSLaunchConfiguration_withBlockDevices (19.48s)
=== RUN TestAccAWSLaunchConfiguration_withVpcClassicLink
--- PASS: TestAccAWSLaunchConfiguration_withVpcClassicLink (19.96s)
=== RUN TestAccAWSLaunchConfiguration_updateEbsBlockDevices
--- PASS: TestAccAWSLaunchConfiguration_updateEbsBlockDevices (24.54s)
=== RUN TestAccAWSLaunchConfiguration_importBasic
--- PASS: TestAccAWSLaunchConfiguration_importBasic (25.89s)
=== RUN TestAccAWSLaunchConfiguration_updateRootBlockDevice
--- PASS: TestAccAWSLaunchConfiguration_updateRootBlockDevice (26.51s)
=== RUN TestAccAWSLaunchConfiguration_ebs_noDevice
--- PASS: TestAccAWSLaunchConfiguration_ebs_noDevice (29.16s)
=== RUN TestAccAWSLaunchConfiguration_withIAMProfile
--- PASS: TestAccAWSLaunchConfiguration_withIAMProfile (30.25s)
@@ -281,15 +281,37 @@ func TestAccAWSLaunchConfiguration_updateEbsBlockDevices(t *testing.T) { | |||
Check: resource.ComposeTestCheckFunc( | |||
testAccCheckAWSLaunchConfigurationExists("aws_launch_configuration.baz", &conf), | |||
resource.TestCheckResourceAttr( | |||
"aws_launch_configuration.baz", "ebs_block_device.2764618555.volume_size", "9"), | |||
"aws_launch_configuration.baz", "ebs_block_device.1393547169.volume_size", "9"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this okay that it changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It worried me too when I saw that, but I did verify that state migration is not necessary:
$ terraform init && terraform apply && terraform plan
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ aws_launch_configuration.baz
id: <computed>
associate_public_ip_address: "false"
ebs_block_device.#: "1"
ebs_block_device.2764618555.delete_on_termination: "true"
ebs_block_device.2764618555.device_name: "/dev/sdb"
ebs_block_device.2764618555.encrypted: "true"
ebs_block_device.2764618555.iops: <computed>
ebs_block_device.2764618555.snapshot_id: <computed>
ebs_block_device.2764618555.volume_size: "9"
ebs_block_device.2764618555.volume_type: <computed>
ebs_optimized: <computed>
enable_monitoring: "true"
image_id: "ami-5189a661"
instance_type: "t2.micro"
key_name: <computed>
name: <computed>
root_block_device.#: "1"
root_block_device.0.delete_on_termination: "true"
root_block_device.0.iops: <computed>
root_block_device.0.volume_size: "11"
root_block_device.0.volume_type: "gp2"
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_launch_configuration.baz: Creating...
associate_public_ip_address: "" => "false"
ebs_block_device.#: "" => "1"
ebs_block_device.2764618555.delete_on_termination: "" => "true"
ebs_block_device.2764618555.device_name: "" => "/dev/sdb"
ebs_block_device.2764618555.encrypted: "" => "true"
ebs_block_device.2764618555.iops: "" => "<computed>"
ebs_block_device.2764618555.snapshot_id: "" => "<computed>"
ebs_block_device.2764618555.volume_size: "" => "9"
ebs_block_device.2764618555.volume_type: "" => "<computed>"
ebs_optimized: "" => "<computed>"
enable_monitoring: "" => "true"
image_id: "" => "ami-5189a661"
instance_type: "" => "t2.micro"
key_name: "" => "<computed>"
name: "" => "<computed>"
root_block_device.#: "" => "1"
root_block_device.0.delete_on_termination: "" => "true"
root_block_device.0.iops: "" => "<computed>"
root_block_device.0.volume_size: "" => "11"
root_block_device.0.volume_type: "" => "gp2"
aws_launch_configuration.baz: Creation complete after 5s (ID: terraform-20180405195506238300000001)
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_launch_configuration.baz: Refreshing state... (ID: terraform-20180405195506238300000001)
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
$ terraform init && terraform plan
Initializing provider plugins...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_launch_configuration.baz: Refreshing state... (ID: terraform-20180405195506238300000001)
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
$ terraform show
aws_launch_configuration.baz:
id = terraform-20180405195506238300000001
associate_public_ip_address = false
ebs_block_device.# = 1
ebs_block_device.2764618555.delete_on_termination = true
ebs_block_device.2764618555.device_name = /dev/sdb
ebs_block_device.2764618555.encrypted = true
ebs_block_device.2764618555.iops = 0
ebs_block_device.2764618555.snapshot_id =
ebs_block_device.2764618555.volume_size = 9
ebs_block_device.2764618555.volume_type =
ebs_optimized = false
enable_monitoring = true
ephemeral_block_device.# = 0
iam_instance_profile =
image_id = ami-5189a661
instance_type = t2.micro
key_name =
name = terraform-20180405195506238300000001
root_block_device.# = 1
root_block_device.0.delete_on_termination = true
root_block_device.0.iops = 0
root_block_device.0.volume_size = 11
root_block_device.0.volume_type = gp2
security_groups.# = 0
spot_price =
vpc_classic_link_id =
vpc_classic_link_security_groups.# = 0
$ terraform refresh
aws_launch_configuration.baz: Refreshing state... (ID: terraform-20180405195506238300000001)
$ terraform show
aws_launch_configuration.baz:
id = terraform-20180405195506238300000001
associate_public_ip_address = false
ebs_block_device.# = 1
ebs_block_device.1393547169.delete_on_termination = true
ebs_block_device.1393547169.device_name = /dev/sdb
ebs_block_device.1393547169.encrypted = true
ebs_block_device.1393547169.iops = 0
ebs_block_device.1393547169.no_device = false
ebs_block_device.1393547169.snapshot_id =
ebs_block_device.1393547169.volume_size = 9
ebs_block_device.1393547169.volume_type =
ebs_optimized = false
enable_monitoring = true
ephemeral_block_device.# = 0
iam_instance_profile =
image_id = ami-5189a661
instance_type = t2.micro
key_name =
name = terraform-20180405195506238300000001
root_block_device.# = 1
root_block_device.0.delete_on_termination = true
root_block_device.0.iops = 0
root_block_device.0.volume_size = 11
root_block_device.0.volume_type = gp2
security_groups.# = 0
spot_price =
vpc_classic_link_id =
vpc_classic_link_security_groups.# = 0
You can see in the last step during refresh
that index is automatically re-computed and plan does not show any diff in the previous step. I don't know the exact reason behind that, but I'm confident that we don't need state migration.
This has been released in version 1.14.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Closes #2132
Original commit & authorship is retained (as usually) - thanks @maxfortune for the initial work.
As described in the commit message I added an acceptance test and reflected the new field in
Read()
so that drifts are detected as user would normally expect.I played with multiple different solutions before eventually choosing this one. While it may not look ideal (due to awkward workaround for
delete_on_termination
), the other ones I considered had more annoying downsides. Here's a complete list of solutions I decided to stash:ebs_block_device
,ephemeral_block_device
&root_block_device
withblock_device_mapping
and nestedebs
field).ebs_block_device
schema to make allEbs
fields actually optional (i.e. nest fields likedelete_on_termination
under newebs
field) and never conflict withNoDevice
.ebs_block_device
is computed - it has no way of knowing whether a value comes explicitly from config or is just computed (newebs
block in this case).Default: true
fromdelete_on_termination
and forcing the user to be explicit.delete_on_termination = true
) and it would also force us to introduce a breaking change as state migration has no way of knowing whether"delete_on_termination": "true"
in state comes from an explicit config or just reflects default value. Making the fieldComputed
wasn't very sound idea either because we'd loose the ability to detect drifts (from defaultdelete_on_termination = true
).