From d2f728e6cda38f2fb1f2c7cb75945c81f6c6920c Mon Sep 17 00:00:00 2001 From: Clint Date: Tue, 7 Mar 2017 06:44:39 -0600 Subject: [PATCH] provider/aws: Only send iops when creating io1 devices. Fix docs (#12392) --- builtin/providers/aws/resource_aws_instance.go | 13 +++++++++---- builtin/providers/aws/resource_aws_instance_test.go | 1 - .../docs/providers/aws/r/instance.html.markdown | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 088193c73..3c0f6a5dc 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -1034,10 +1034,15 @@ func readBlockDeviceMappingsFromConfig( if v, ok := bd["volume_type"].(string); ok && v != "" { ebs.VolumeType = aws.String(v) - } - - if v, ok := bd["iops"].(int); ok && v > 0 { - ebs.Iops = aws.Int64(int64(v)) + if "io1" == strings.ToLower(v) { + // Condition: This parameter is required for requests to create io1 + // volumes; it is not used in requests to create gp2, st1, sc1, or + // standard volumes. + // See: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html + if v, ok := bd["iops"].(int); ok && v > 0 { + ebs.Iops = aws.Int64(int64(v)) + } + } } blockDevices = append(blockDevices, &ec2.BlockDeviceMapping{ diff --git a/builtin/providers/aws/resource_aws_instance_test.go b/builtin/providers/aws/resource_aws_instance_test.go index aae53ecbd..f4ace2c44 100644 --- a/builtin/providers/aws/resource_aws_instance_test.go +++ b/builtin/providers/aws/resource_aws_instance_test.go @@ -1060,7 +1060,6 @@ resource "aws_instance" "foo" { root_block_device { volume_type = "gp2" volume_size = 11 - iops = 330 } } ` diff --git a/website/source/docs/providers/aws/r/instance.html.markdown b/website/source/docs/providers/aws/r/instance.html.markdown index fe3491d62..a71080a87 100644 --- a/website/source/docs/providers/aws/r/instance.html.markdown +++ b/website/source/docs/providers/aws/r/instance.html.markdown @@ -102,7 +102,8 @@ The `root_block_device` mapping supports the following: * `volume_size` - (Optional) The size of the volume in gigabytes. * `iops` - (Optional) The amount of provisioned [IOPS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-io-characteristics.html). - This must be set with a `volume_type` of `"io1"`. + This is only valid for `volume_type` of `"io1"`, and must be specified if + using that type * `delete_on_termination` - (Optional) Whether the volume should be destroyed on instance termination (Default: `true`).