-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
aws_instance accepts iops = 0 on non-io1 root_block_device #7765
Comments
Further research seems to show that #4146 may apply here |
It looks like the change there somewhat applies; setting to 0 does produce the PRs described behavior; however I would have to do some math, or a lookup against disk types for static IOPS values. However, no matter the value, if the disk isn't an Doing this for all EBS types (additional and |
I made the following changes:
While it does bypass the IOPS issue I was considering an warning message (not sure this is the right place given the lack of this sort of thing here). Ideally I would like the overridden value of |
In builtin/providers/aws/resource_aws_ebs_volume.go
I'm guessing that this only applies to a resource |
The above change results in a complete ignoring of IOPS when the instance doesn't have an io1 disk type. Should warnings be emitted? is there a better pace to do this? Should I trim out the block comment? |
@mengesb a warning about an incompatible option-to-volume-type would be a nice touch for the user, so that they might spot something potentially wrong in their template. Might save them some troubleshooting time, etc. |
ah HA! got it!
|
so that message can be customized of course, but I did get the error reporting; only question now would be how to show that in the plan... or if that's even worth it. |
If someone would comment about this suggested change that'd be great, but otherwise I might open a PR with this as-is. diff --git i/builtin/providers/aws/resource_aws_instance.go w/builtin/providers/aws/resource_aws_instance.go
index 7681d6e..aa248bf 100644
--- i/builtin/providers/aws/resource_aws_instance.go
+++ w/builtin/providers/aws/resource_aws_instance.go
@@ -931,8 +931,16 @@ func readBlockDeviceMappingsFromConfig(
ebs.VolumeType = aws.String(v)
}
- if v, ok := bd["iops"].(int); ok && v > 0 {
+ if v, ok := bd["iops"].(int); ok && v > 0 && *ebs.VolumeType == "io1" {
+ // Only set the iops attribute if the volume type is io1. Setting otherwise
+ // can trigger a refresh/plan loop based on the computed value that is given
+ // from AWS, and prevent us from specifying 0 as a valid iops.
+ // See https://github.com/hashicorp/terraform/pull/4146
+ // See https://github.com/hashicorp/terraform/issues/7765
ebs.Iops = aws.Int64(int64(v))
+ } else if v, ok := bd["iops"].(int); ok && v > 0 && *ebs.VolumeType != "io1" {
+ // Message user about incompatibility
+ log.Printf("[WARN] iops attribute only valid with 'io1' volume type.")
}
if dn, err := fetchRootDeviceName(d.Get("ami").(string), conn); err == nil { |
@mengesb if you open a PR, then it is going to be easier to comment on the change. If there are any tests (see: resource_aws_instance_test.go, make sure that they pass and amend accordingly so that you validate this scenario in a test. Otherwise, looks very good! 🍰 P.S. You can re-use warning message from here: resource_aws_ebs_volume.go#L104. Just for consistency. |
Closed via #7783 |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
There should be some exclusion in the
aws_instance
resource forroot_block_device
.When using anything other than
io1
forroot_block_device.volume_type
, if the user provides aniops
it should be ignored. Currently it doesn't ignore it, so any value results in an error:except when
iops = 0
:Trouble is when you need it (using
io1
volume types, you should provide it, however since there's no logic to include or exclude a parameter, the plugin should handle this gracefully.Enhancement: when usiong
io1
disk types andiops
is not provided, maybe assume the logical maximum (X GiB * 30 = IOPS) with a floor of 100 and a roof of 20000.Terraform Version
Terraform v0.6.16
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
Debug Output
https://gist.github.com/anonymous/53ceef2dfdc20e2db0757dd734b0b46a
Panic Output
N/A
Expected Behavior
Any value provided to
iops
should result in the same error of being invalid when added to non-io1
volume types; OR (preferred) ignore and exclude theiops
parameter on non-io1 volume types.Actual Behavior
A value of
0
foriops
results in successful processing. Any other value results in an errorSteps to Reproduce
terraform apply
Important Factoids
Running on AWS; no other specifics
References
N/A
The text was updated successfully, but these errors were encountered: