-
Notifications
You must be signed in to change notification settings - Fork 118
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
random_shuffle need to add position 0 of an array to return 1 single result string #508
Comments
Hi @mrk-qa 👋 Thank you for raising this issue. Since the Terraform generally uses a static type system throughout to enable static validation of configuration and other practitioner-related enhancements, such as producing higher fidelity error messaging about data handling. This model extends to providers, where provider authors generally should choose a single static type to represent attributes (whether computed or not). While it would be technically possible to implement a dynamic type constraint for the Rather than changing the existing For example: # This is a design sketch of what a proposed managed resource
# for selecting a single value out of a list/set might look like. It
# is not available in the hashicorp/random provider today.
resource "random_selection" "example" {
input = ["one", "two", "three"]
}
output "example" {
# one of: "one", "two", or "three"
value = random_selection.example.result
} This sort of feature request would be less contentious for consideration since the implementation can be done without potentially impacting existing Please let us know. Thanks! |
Closing due to lack of response. If someone would like the solution outlined above or wants to suggest another change without configuration validation considerations for this use case, please comment before this issue is automatically locked or create a new issue. Thanks. |
Terraform CLI and Provider Versions
Terraform v1.6.6
hashicorp/random v3.6.0
Terraform Configuration
Expected Behavior
Expected that if result_count = 1, return a string
Actual Behavior
Returned an array containing string
Steps to Reproduce
terraform init
terraform apply
How much impact is this issue causing?
Low
Logs
No response
Additional Information
The alternative solution was to add an array at position 0 to return a string only.
Example:
resource "random_shuffle" "types_instance_aws" {
input = ["t2.nano", "t2.micro", "t2.small", "t2.medium"]
result_count = 1
}
output "instance_types_aws" {
value = random_shuffle.types_instance_aws.result[0]
}
Code of Conduct
The text was updated successfully, but these errors were encountered: