hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

[Bug]: For this Terraform resource block Resource: aws_fsx_openzfs_file_system the "Disk Iops Configuration" block does not work properly with AUTOMATIC MODE. #30435

Open swapnilitape opened 1 year ago

swapnilitape commented 1 year ago

Terraform Core Version

4.61.0

AWS Provider Version

4.46.0

Affected Resource(s)

Resource: aws_fsx_openzfs_file_system

[Bug]: For this Terraform resource block Resource: aws_fsx_openzfs_file_system the "Disk Iops Configuration" block does not work properly with AUTOMATIC MODE.

Expected Behavior

resource "aws_fsx_openzfs_file_system" "test" { storage_capacity = 64 subnet_ids = [aws_subnet.test1.id] deployment_type = "SINGLE_AZ_1" throughput_capacity = 64

disk_iops_configuration { mode = "AUTOMATIC" iops = null --> here it should be optional value and it should ignore the iops for mode AUTOMATIC. }

}

Actual Behavior

When we use the mode as "AUTOMATIC" it should not ask for the IOPS. but in terraform code it tries to take the value and fails with below error.

Error: creating FSx OpenZFS File System: BadRequest: 1 validation error detected: Value '0' at 'openZFSConfiguration.diskIopsConfiguration.iops' failed to satisfy constraint: Member must have value greater than or equal to 1.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_fsx_openzfs_file_system" "test" { storage_capacity = 64 subnet_ids = [aws_subnet.test1.id] deployment_type = "SINGLE_AZ_1" throughput_capacity = 64

disk_iops_configuration { mode = "AUTOMATIC" iops = null }

}

Steps to Reproduce

When we use the mode as "AUTOMATIC" it should not ask for the IOPS. but in terraform code it tries to take the value and fails with below error.

Error: creating FSx OpenZFS File System: BadRequest: 1 validation error detected: Value '0' at 'openZFSConfiguration.diskIopsConfiguration.iops' failed to satisfy constraint: Member must have value greater than or equal to 1.

Debug Output

No response

Panic Output

When we use the mode as "AUTOMATIC" it should not ask for the IOPS. but in terraform code it tries to take the value and fails with below error.

Error: creating FSx OpenZFS File System: BadRequest: 1 validation error detected: Value '0' at 'openZFSConfiguration.diskIopsConfiguration.iops' failed to satisfy constraint: Member must have value greater than or equal to 1.

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

acwwat commented 9 months ago

The same problem exists with the aws_fsx_ontap_file_system resource with AWS Provider v5.16.2 and Terraform v5.10.0. If I set mode to AUTOMATIC in the disk_iops_configuration block, I get the following error:

 Error: creating FSx ONTAP File System: BadRequest: 1 validation error detected: Value '0' at 'ontapConfiguration.diskIopsConfiguration.iops' failed to satisfy constraint: Member must have value greater than or equal to 1
│
│   with aws_fsx_ontap_file_system.this2,
│   on shared-storage.tf line 490, in resource "aws_fsx_ontap_file_system" "this2":
│  490: resource "aws_fsx_ontap_file_system" "this2" {

And if I set iops to 1 or any value in attempt to work around the constraint, I get the following error instead:

Error: creating FSx ONTAP File System: BadRequest: Invalid DiskIopsConfiguration provided. IOPS cannot be set with AUTOMATIC mode.
│
│   with aws_fsx_ontap_file_system.this2,
│   on shared-storage.tf line 490, in resource "aws_fsx_ontap_file_system" "this2":
│  490: resource "aws_fsx_ontap_file_system" "this2" {

Updated: For reference, it looks like the provider is passing in 0 for iops as a "default value" if not specified in the TF configuration:

http.request.body="{"ClientRequestToken":"terraform-20230918014501894900000001","FileSystemType":"ONTAP","OntapConfiguration":{"AutomaticBackupRetentionDays":30,"DailyAutomaticBackupStartTime":"07:00","DeploymentType":"MULTI_AZ_1","DiskIopsConfiguration":{"Iops":0,"Mode":"AUTOMATIC"},"FsxAdminPassword":"<REDACTED>","PreferredSubnetId":"<REDACTED>","ThroughputCapacity":128,"WeeklyMaintenanceStartTime":"7:08:00"},"StorageCapacity":1024,"StorageType":"SSD","SubnetIds":["<REDACTED>","<REDACTED>"],"Tags":[{"Key":"Name","Value":"<REDACTED>"}]}

Based on this, is the fix perhaps to set Default to nil in the schema? I've not worked with Go nor Terraform provider code so I am just speculating here.

gwolski commented 5 months ago

I have upgraded to AWS Provider v5.32.1 this evening and as @acwwat shows above, I still get the validation error of " Value '0' at 'ontapConfiguration.diskIopsConfiguration.iops' failed to satisfy constraint: Member must have value greater than or equal to 1" when using aws_fsx_ontap_file_system resource.

My code is :

disk_iops_configuration { iops = null mode = "AUTOMATIC" }

bobnautic commented 3 weeks ago

bump