You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Give the user of your module the option to disable creation of certain resources or modules
Attempted Solutions
Use "count" (or different name) where 0 means disabled, and 1 means enabled.
This solution works but causes the resource to become a list of resources. Eg
causes abc_type.something to be a list of length 1 if "enabled" is true. This means everywhere in the code that this single resource is referenced, a '[0]' must be appended. This adds noise to the code and obfuscates intent.
The usage of "count" meta-variable has worked but it is now time for HCL2 resources to get a proper "enabled" meta-variable.
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.
ghost
locked as resolved and limited conversation to collaborators
Mar 29, 2021
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current Terraform Version
Use-cases
Give the user of your module the option to disable creation of certain resources or modules
Attempted Solutions
Use "count" (or different name) where 0 means disabled, and 1 means enabled.
This solution works but causes the resource to become a list of resources. Eg
causes abc_type.something to be a list of length 1 if "enabled" is true. This means everywhere in the code that this single resource is referenced, a '[0]' must be appended. This adds noise to the code and obfuscates intent.
The usage of "count" meta-variable has worked but it is now time for HCL2 resources to get a proper "enabled" meta-variable.
Proposal
HCL2 should support the following syntax:
If enabled is false, the resource should not be instantiated.
The text was updated successfully, but these errors were encountered: