diff --git a/lib/terraforming/template/tf/ec2.erb b/lib/terraforming/template/tf/ec2.erb index 9b428f47..1fbb977c 100644 --- a/lib/terraforming/template/tf/ec2.erb +++ b/lib/terraforming/template/tf/ec2.erb @@ -27,10 +27,10 @@ resource "aws_instance" "<%= module_name_of(instance) %>" { root_block_device { volume_type = "<%= block_device.volume_type %>" volume_size = <%= block_device.size %> -<%- if block_device.iops -%> + delete_on_termination = <%= mapping.ebs.delete_on_termination %> +<%- if block_device.volume_type == "io1" && block_device.iops -%> iops = <%= block_device.iops %> <%- end -%> - delete_on_termination = <%= mapping.ebs.delete_on_termination %> } <%- else -%> ebs_block_device { @@ -38,10 +38,10 @@ resource "aws_instance" "<%= module_name_of(instance) %>" { snapshot_id = "<%= block_device.snapshot_id %>" volume_type = "<%= block_device.volume_type %>" volume_size = <%= block_device.size %> -<%- if block_device.iops -%> + delete_on_termination = <%= mapping.ebs.delete_on_termination %> +<%- if block_device.volume_type == "io1" && block_device.iops -%> iops = <%= block_device.iops %> <%- end -%> - delete_on_termination = <%= mapping.ebs.delete_on_termination %> } <% end -%> diff --git a/spec/lib/terraforming/resource/ec2_spec.rb b/spec/lib/terraforming/resource/ec2_spec.rb index 9a140799..d9b53dda 100644 --- a/spec/lib/terraforming/resource/ec2_spec.rb +++ b/spec/lib/terraforming/resource/ec2_spec.rb @@ -278,7 +278,8 @@ module Resource delete_on_termination: true } ], - volume_type: "standard", + volume_type: "io1", + iops: 24, encrypted: false } ] @@ -332,9 +333,10 @@ module Resource source_dest_check = true root_block_device { - volume_type = "standard" + volume_type = "io1" volume_size = 8 delete_on_termination = true + iops = 24 } tags { @@ -360,7 +362,6 @@ module Resource snapshot_id = "snap-5678efgh" volume_type = "gp2" volume_size = 8 - iops = 24 delete_on_termination = true }