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
The proposal here is to create a new meta-parameter that would allow to control the state of a single resource.
This is useful for cases when a resource must be destroyed and we want to keep the code, or specially when we want to enable/disable a resource without turning it into an array of resources - which means the references to the resource are kept unchanged.
A similar behaviour can be found in other configuration languages. For example in Puppet, we can use ensure => absent and in Ansible we can use state: absent.
Attempted Solutions
The current behaviour today can be achieved with count and a condition, for example:
However in this case we don't have a single resource, but an array of resources. So, any further reference to this object must be adapted - Although we know there's only one resource because of ? 1 : 0.
With this proposal, not only the code would be cleaner because we don't need a condition block neither array references, but we know there is either zero or one resource.
Applying the concept to the previous snippets, and assuming here a meta-parameter called enabled which accepts a boolean value, we'd have as follows:
variable "enable_green_application" {
default = false
type = bool
}
resource "aws_instance" "application_green" {
enabled = var.enable_green_application # new meta parameter in action
instance_type = "t2.micro"
[...]
resource "aws_elb" "application_green" {
enabled = var.enable_green_application
name = "${var.prefix}-green-elb"
[...]
instances = aws_instance.application_green.id # no more array references
[...]
resource "aws_route53_record" "application_green" {
enabled = var.enable_green_application
[...]
alias {
name = aws_elb.application_green.dns_name # no more array references
zone_id = aws_elb.application_green.zone_id
evaluate_target_health = true
}
[...]
References
No response
The text was updated successfully, but these errors were encountered:
Indeed thanks for sharing this proposal, @mattsafraid!
I think this proposal is essentially the same as #21953. Would you agree? If so, I'd like to close this just to consolidate the discussion in one place.
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.
Terraform Version
Use Cases
The proposal here is to create a new meta-parameter that would allow to control the state of a single resource.
This is useful for cases when a resource must be destroyed and we want to keep the code, or specially when we want to enable/disable a resource without turning it into an array of resources - which means the references to the resource are kept unchanged.
A similar behaviour can be found in other configuration languages. For example in Puppet, we can use
ensure => absent
and in Ansible we can usestate: absent
.Attempted Solutions
The current behaviour today can be achieved with
count
and a condition, for example:From https://www.hashicorp.com/blog/terraform-feature-toggles-blue-green-deployments-canary-test
However in this case we don't have a single resource, but an array of resources. So, any further reference to this object must be adapted - Although we know there's only one resource because of
? 1 : 0
.Proposal
With this proposal, not only the code would be cleaner because we don't need a condition block neither array references, but we know there is either zero or one resource.
Applying the concept to the previous snippets, and assuming here a meta-parameter called
enabled
which accepts a boolean value, we'd have as follows:References
No response
The text was updated successfully, but these errors were encountered: