Skip to content
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

Read iops only when volume type is io1 #1573

Merged
merged 1 commit into from
Sep 21, 2017
Merged

Conversation

fraenkel
Copy link
Contributor

@fraenkel fraenkel commented Sep 1, 2017

Iops can only be specified when the volume type is io1. The current code
handles that.
When the iops are read, it should only record the value when the volume
type is io1 otherwise it can conflict with what is specified but never
applied.

fixes #1521

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Sep 6, 2017
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fraenkel

Thanks for the suggested change here.
Asked for a small change, and would like to get your point on my second comment.

Thanks!

}
if vol.Iops != nil {
bd["iops"] = *vol.Iops
if "io1" == strings.ToLower(*vol.VolumeType) && vol.Iops != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I would prefer to write the state in both io1 & gp2 cases: when gp2 is used, the iops are 3 times the volume size with a minimum of 100gb. So if you have a 34GB volume, it would result in 104 iops.
I think it's worth keeping that information for people wanting to know it.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ninir Regarding your second comment, a problem I see with keeping state for gp2 volume iops is that anybody managing EBS volumes with Terraform would have to keep track of the iops multiplier and update 2 values when adding/changing gp2 volumes.
IMHO, there's little discernible benefit to having to manage this number unless it is io1.

It might also create confusion for users who think they could change iops on a gp2 volume when they cannot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use the type and perform the calculation for gp2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that @fraenkel!

@mrwacky42 Could you clarify the part about anybody managing EBS volumes with Terraform would have to keep track of the iops multiplier and update 2 values when adding/changing gp2 volumes please?
Your point seems interesting, however not sure to get it right! 😅

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ninir -
The current expectation is that I do not have to specify iops for gp2 volumes because it is meaningless. I worry that mapping values for gp2 volume iops would force me to change my Terraform config from:

resource "aws_instance" "foo" {
  ...
  root_block_device {
    volume_type = "gp2"
    volume_size = "500"
  }
}

to include iops in order to avoid Terraform thinking the resource is changed on every run:

resource "aws_instance" "foo" {
  ...
  root_block_device {
    volume_type = "gp2"
    volume_size = "500"
    iops = "1500"
  }
}

However, I could be misunderstanding the how the code change affects everything, so feel free to disregard!

See also the PR and issue mentioned in the comments:
https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_instance.go#L1388-L1394

@fraenkel
Copy link
Contributor Author

fraenkel commented Sep 6, 2017

Sorry, I need to redo this. I realized I did this all backwards now.

@mrwacky42
Copy link
Contributor

See also: hashicorp/terraform#7765

@fraenkel
Copy link
Contributor Author

fraenkel commented Sep 7, 2017

This doesn't actually fix anything.... I am trying to see if it is at all possible.

@fraenkel
Copy link
Contributor Author

fraenkel commented Sep 7, 2017

Ok, I found a way to make this work. I wish there was a good way to test this.
My test is to do an apply followed by a plan.

@fraenkel fraenkel force-pushed the gp2iops branch 2 times, most recently from cbf8e8c to 45f0935 Compare September 7, 2017 22:10
vt := k[:i+1] + "volume_type"
v := d.Get(vt).(string)
return strings.ToLower(v) != ec2.VolumeTypeIo1
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a function so that both DiffSuppressFunc blocks can use it?

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ninir Done

@Ninir Ninir added the waiting-response Maintainers are waiting on response from community or contributor. label Sep 18, 2017
Iops can only be specified with io1. Only perform the diff when the
volume_type is io1.
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fraenkel

LGTM !

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSInstance_'           
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSInstance_ -timeout 120m
=== RUN   TestAccAWSInstance_importBasic
--- PASS: TestAccAWSInstance_importBasic (146.58s)
=== RUN   TestAccAWSInstance_importInDefaultVpc
--- PASS: TestAccAWSInstance_importInDefaultVpc (145.48s)
=== RUN   TestAccAWSInstance_importInEc2Classic
--- SKIP: TestAccAWSInstance_importInEc2Classic (2.25s)
	provider_test.go:69: This test can only run in EC2 Classic, platforms available in us-west-2: ["VPC"]
=== RUN   TestAccAWSInstance_basic
--- PASS: TestAccAWSInstance_basic (204.75s)
=== RUN   TestAccAWSInstance_userDataBase64
--- PASS: TestAccAWSInstance_userDataBase64 (139.13s)
=== RUN   TestAccAWSInstance_GP2IopsDevice
--- PASS: TestAccAWSInstance_GP2IopsDevice (94.64s)
=== RUN   TestAccAWSInstance_blockDevices
--- PASS: TestAccAWSInstance_blockDevices (100.26s)
=== RUN   TestAccAWSInstance_rootInstanceStore
--- PASS: TestAccAWSInstance_rootInstanceStore (109.34s)
=== RUN   TestAccAWSInstance_noAMIEphemeralDevices
--- PASS: TestAccAWSInstance_noAMIEphemeralDevices (69.03s)
=== RUN   TestAccAWSInstance_sourceDestCheck
--- PASS: TestAccAWSInstance_sourceDestCheck (236.43s)
=== RUN   TestAccAWSInstance_disableApiTermination
--- PASS: TestAccAWSInstance_disableApiTermination (201.57s)
=== RUN   TestAccAWSInstance_vpc
--- PASS: TestAccAWSInstance_vpc (125.59s)
=== RUN   TestAccAWSInstance_ipv6_supportAddressCount
--- PASS: TestAccAWSInstance_ipv6_supportAddressCount (123.10s)
=== RUN   TestAccAWSInstance_ipv6AddressCountAndSingleAddressCausesError
--- PASS: TestAccAWSInstance_ipv6AddressCountAndSingleAddressCausesError (32.58s)
=== RUN   TestAccAWSInstance_ipv6_supportAddressCountWithIpv4
--- PASS: TestAccAWSInstance_ipv6_supportAddressCountWithIpv4 (150.79s)
=== RUN   TestAccAWSInstance_multipleRegions
--- PASS: TestAccAWSInstance_multipleRegions (142.35s)
=== RUN   TestAccAWSInstance_NetworkInstanceSecurityGroups
--- PASS: TestAccAWSInstance_NetworkInstanceSecurityGroups (150.36s)
=== RUN   TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs
--- PASS: TestAccAWSInstance_NetworkInstanceVPCSecurityGroupIDs (143.97s)
=== RUN   TestAccAWSInstance_tags
--- PASS: TestAccAWSInstance_tags (157.77s)
=== RUN   TestAccAWSInstance_volumeTags
--- PASS: TestAccAWSInstance_volumeTags (180.97s)
=== RUN   TestAccAWSInstance_volumeTagsComputed
--- PASS: TestAccAWSInstance_volumeTagsComputed (141.31s)
=== RUN   TestAccAWSInstance_instanceProfileChange
--- PASS: TestAccAWSInstance_instanceProfileChange (161.38s)
=== RUN   TestAccAWSInstance_withIamInstanceProfile
--- PASS: TestAccAWSInstance_withIamInstanceProfile (135.49s)
=== RUN   TestAccAWSInstance_privateIP
--- PASS: TestAccAWSInstance_privateIP (154.36s)
=== RUN   TestAccAWSInstance_associatePublicIPAndPrivateIP
--- PASS: TestAccAWSInstance_associatePublicIPAndPrivateIP (140.39s)
=== RUN   TestAccAWSInstance_keyPairCheck
--- PASS: TestAccAWSInstance_keyPairCheck (84.21s)
=== RUN   TestAccAWSInstance_rootBlockDeviceMismatch
--- PASS: TestAccAWSInstance_rootBlockDeviceMismatch (130.97s)
=== RUN   TestAccAWSInstance_forceNewAndTagsDrift
--- PASS: TestAccAWSInstance_forceNewAndTagsDrift (216.95s)
=== RUN   TestAccAWSInstance_changeInstanceType
--- PASS: TestAccAWSInstance_changeInstanceType (175.24s)
=== RUN   TestAccAWSInstance_primaryNetworkInterface
--- PASS: TestAccAWSInstance_primaryNetworkInterface (155.32s)
=== RUN   TestAccAWSInstance_primaryNetworkInterfaceSourceDestCheck
--- PASS: TestAccAWSInstance_primaryNetworkInterfaceSourceDestCheck (151.76s)
=== RUN   TestAccAWSInstance_addSecondaryInterface
--- PASS: TestAccAWSInstance_addSecondaryInterface (248.56s)
=== RUN   TestAccAWSInstance_addSecurityGroupNetworkInterface
--- PASS: TestAccAWSInstance_addSecurityGroupNetworkInterface (350.60s)
=== RUN   TestAccAWSInstance_associatePublic_defaultPrivate
--- PASS: TestAccAWSInstance_associatePublic_defaultPrivate (149.95s)
=== RUN   TestAccAWSInstance_associatePublic_defaultPublic
--- PASS: TestAccAWSInstance_associatePublic_defaultPublic (129.93s)
=== RUN   TestAccAWSInstance_associatePublic_explicitPublic
--- PASS: TestAccAWSInstance_associatePublic_explicitPublic (130.13s)
=== RUN   TestAccAWSInstance_associatePublic_explicitPrivate
--- PASS: TestAccAWSInstance_associatePublic_explicitPrivate (139.67s)
=== RUN   TestAccAWSInstance_associatePublic_overridePublic
--- PASS: TestAccAWSInstance_associatePublic_overridePublic (132.82s)
=== RUN   TestAccAWSInstance_associatePublic_overridePrivate
--- PASS: TestAccAWSInstance_associatePublic_overridePrivate (173.61s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	5759.656s

@Ninir Ninir merged commit 5857910 into hashicorp:master Sep 21, 2017
@Ninir Ninir removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 21, 2017
nbaztec pushed a commit to nbaztec/terraform-provider-aws that referenced this pull request Sep 26, 2017
Read iops only when volume type is io1
@ghost
Copy link

ghost commented Apr 11, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IOPs not ignored when volume_type != "io1" when instance read
3 participants