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.76k stars 9.12k forks source link

[Enhancement]: #38029

Closed prowlaiii closed 2 months ago

prowlaiii commented 3 months ago

Description

I often use a for_each statement as an "if" to conditionally deploy resources or modules based on feature flags or other options, but then each resource when its used needs to be presented as if it had an iterator eg. my_resource["yes"]. Would it be possible to implement an "if" operator instead, which would make the code more readable and also remove the pseudo iterator from calls to it (and also terraform output). Something like: deploy_if = <condition> rather than: for_each = <condition> ? {deploy="yes"} : {} or: count = <condition> ? 1 : 0

Affected Resource(s) and/or Data Source(s)

(none)

Potential Terraform Configuration

resource "xxxxxx" "my_blah" {
   deploy_if = var.options.i_want_my_blah
   .....
}

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 2 months ago

Hey @prowlaiii 👋 Thank you for taking the time to raise this! For changes to how Terraform operates at its core, you'll want to open a feature request in the Terraform Core repository, rather than at the AWS provider level (this repository). With that in mind, I'm going to close this issue.

github-actions[bot] commented 2 months ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

github-actions[bot] commented 1 month ago

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.