terraform-provider-random
terraform-provider-random copied to clipboard
Documentation for special flag unclear
Terraform CLI and Provider Versions
3.4.3
Terraform Configuration
resource "random_password" "password" {
length = 16
special = false
min_lower = 2
min_numeric = 2
min_special = 2
min_upper = 2
numeric = true
upper = true
lower = true
}
Expected Behavior
The special attribute should override or throw an error when set to false and the min_special attribute is set to a non null value.
or
The documentation should be clear that the special attribute is overridden by the min_special attribute.
Actual Behavior
This results in a password with 2 special characters even though special is set to false.
Steps to Reproduce
terraform apply
How much impact is this issue causing?
Low
Logs
No response
Additional Information
I was able to write around this issue by using checks within the module but felt this was worth reporting as it is confusing.
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Hi @mcarter106 👋 Thank you for raising this, very understandable that this behavior is likely confusing right now. The resource's preference should likely be to respect the special = false configuration over anything specified by min_special.
As a followup to fixing that particular behavior, it may make sense for the resource to raise a validation warning if min_special is declared at the same time as special = false, to ensure maintainers of the resource configuration understand what is valid, however that would potentially make modular configurations a little harder to not show the potential validation warning:
resource "random_pet" "example" {
# ...
special = var.make_special ? true : false
min_special = var.make_special ? 2 : null
}
This was the work around we used in our code. I just wanted to surface the issue so that maybe the documentation could make this a little more clear for the next developer. Thank you
From: Brian Flad @.> Sent: Monday, September 19, 2022 8:56 AM To: hashicorp/terraform-provider-random @.> Cc: Michelle Carter @.>; Mention @.> Subject: Re: [hashicorp/terraform-provider-random] Documentation for special flag unclear (Issue #323)
Hi @mcarter106https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmcarter106&data=05%7C01%7Cmiccarter%40microsoft.com%7Cf3e87aae59ed43fe452508da9a46a5cd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637991925475981495%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fRa4r2RY4nFuViTfTYLS%2BGOAS%2Fe5Hu1LwWmxdXgAG60%3D&reserved=0 👋 Thank you for raising this, very understandable that this behavior is likely confusing right now. The resource's preference should likely be to respect the special = false configuration over anything specified by min_special.
As a followup to fixing that particular behavior, it may make sense for the resource to raise a validation warning if min_special is declared at the same time as special = false, to ensure maintainers of the resource configuration understand what is valid, however that would potentially make modular configurations a little harder to not show the potential validation warning:
resource "random_pet" "example" {
...
special = var.make_special ? true : false
min_special = var.make_special ? 2 : null
}
— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fhashicorp%2Fterraform-provider-random%2Fissues%2F323%23issuecomment-1251055066&data=05%7C01%7Cmiccarter%40microsoft.com%7Cf3e87aae59ed43fe452508da9a46a5cd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637991925476137615%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UTP4mYy7EdeK%2Ba77kvi0H2IEqymZs4isvfZJ0UnQlkk%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FALK55MPKEJCXTYGLJV27EQ3V7BWGBANCNFSM6AAAAAAQOS46BA&data=05%7C01%7Cmiccarter%40microsoft.com%7Cf3e87aae59ed43fe452508da9a46a5cd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637991925476137615%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Gz2v4Tcb8bWG4zYj9BK7Xo0NsrUtnKNWLVINUGkLGw8%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>