Skip to content
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

Meta-Argument condition or include_if & content #29314

Closed
damon-atkins opened this issue Aug 6, 2021 · 3 comments
Closed

Meta-Argument condition or include_if & content #29314

damon-atkins opened this issue Aug 6, 2021 · 3 comments
Labels
enhancement new new issue not yet triaged

Comments

@damon-atkins
Copy link

damon-atkins commented Aug 6, 2021

Current Terraform Version

All

Use-cases

The Meta-Argument count and new for_each are used to perform "if statements" in the case of count 0 or 1, in the case for_each empty set or set

Proposal

a) Provide a new Meta-Argument like condition or include_if instead of using count and for_each as a workaround for a if
b) allow resource information to be provided as content i.e. pass a data structue which represents the same lines as the DSL

I am surprise you can not do

locals {
   something = {
      prevent_destroy = true
    }
}
dynamic "lifecycle" {
    condition = can(var.ENVIRONMENT)
    content = something  # as long as the map is what the resource expects in this block. i.e. its passing prevent_destroy
}

And also

resource "abc" "xyz" {
     somesetting = var.ENVIRONMENT
}

As

resource "abc" "xyz" {
    dynamic "somesetting" {
      condition = can(var.ENVIRONMENT)
      content = var.ENVIRONMENT
}
@jbardin
Copy link
Member

jbardin commented Aug 6, 2021

Thanks @damon-atkins, combining with #21953 which covers the same use case.

@jbardin jbardin closed this as completed Aug 6, 2021
@damon-atkins
Copy link
Author

Thanks. Did not spot the existing issue.

@github-actions
Copy link

github-actions bot commented Sep 7, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants