-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
ignore_changes for set arguments #26359
Comments
I apologize for the stupid question, but shouldn't you just be doing |
@nexxai, blocks are always contained within their respective data type, and must be addressed accordingly. This means that a List element would always require and index, and a Set element is not addressable. In older versions of Terraform, individual resources with a count of 1 could be referenced either way, but that behavior was also deprecated to allow for more strict handling of data types. |
Got it. Makes sense. Thank you for the explanation! |
So, how should it be addressed? |
Is there a workaround for this issue? When a fix can be expected? |
It seems like this particular problem has a root cause which has no clear solution, but that there are also some specific situations which are in principle simpler to handle but still require being able to describe something that isn't describable in the language today. The root problem here is that by definition elements of a set doesn't have any key or index to look them up by. Set elements are defined by their contents, but that isn't helpful in a situation like In discussions about this so far I don't think anyone's been able to offer a feasible design for solving this in the general case, but there are two specific situations that are, in theory at least, a bit easier to deal with:
We already have the function In principle we could support It also isn't clear to me that such a solution would be sufficient anyway. This particular example only has one My sense is that the most practical answer here would be that any block type that might potentially need to have traversals into it (whether in
Both of these are supported by Terraform Core today, but map-based blocks in particular are not supported by the legacy SDK that With all of this said then: for me it seems like the most viable path forward is to move away from using sets of objects to represent multiple blocks in most cases, because that offers a clear way to talk about individual blocks when writing traversal expressions elsewhere in the configuration. However, I don't see any easy direct path to that or any other solution, because changing the data type of an attribute or block in an existing resource type is a breaking change. |
We just ran into the same problem, but for our use case it would be totally sufficient if all origins (just one exists) would be ignored, so we tried resource "aws_cloudfront_distribution" "distro" {
// …
lifecycle {
ignore_changes = [origin,etag,last_modified_time]
}
// …
} but we still get changes |
|
Would it not be possible to allow for expression with an if clause when ignoring changes? It could still be limited to not allow function calls or other problematic stuff. Another solution I can see would be to allow using lifecycle directive inside of all blocks, so you could have it inside the origin block and the reference there would be local. |
For context, we have the exact same issue with the ibm_database resource, IBM decided to use a set for dynamic disc allocation, it changes over time, and we cannot ignore it. See group->disk->allocation_mb. |
One more joining the party here, affecting When configuring the default_action of an resource "aws_lb_listener" "test" {
(...)
default_action {
type = "forward"
forward {
target_group {
arn = foo
weight = 100
}
target_group {
arn = bar
weight = 0
}
}
}
} For blue/green deployments we would like to control these weight values outside Terraform but we cannot ignore them without ignoring the whole |
it seems there's a recent change on the said ECS Blue/Green deployments with CodeDeploy. Lately CodeDeploy leaves both target group attached at the end of deployments, so we need to ignore the 2 target group blocks. |
@salvianreynaldi I don't know about whatever resource you're using, but on aws_lb_listener to ignore the forward rule default_action I think we did: ignore_changes = [
default_action[0].forward[0]
] |
Sets do not have individually addressable items but it still makes sense to want to ignore changes to all of them. This is also a pattern appearing in list items, wanting to ignore changes to all of them. A syntax such as the following would solve both
|
This is exactly what is needed. |
Currently I had to put a rotated secrets in custom header in AWS Cloudfront distribution origin. ignore_changes = [
origin[*].custom_header[*].value
] |
Any news on this? I have the same issue. |
Any update on this? We are facing the same issue. |
This not work with some resources it showing below error
|
Running into this problem with Fastly provider trying to ignore programmatic changes to a Dictionary done outside of Terraform. |
Same issue when I try to ignore changes on Resource |
I have the same problem for azurerm, trying to ignore notification.contact_groups for Resource azurerm_consumption_budget_subscription |
I'm setting up a helm release from terraform and I need this as well |
We are using custom headers to increase security in the communication between cloudfront and origin, as recommended by aws. The custom header is modified by a process outside of Terraform, so we need to add
ignore_changes
tocustom_headers
.Terraform Version
Terraform Configuration Files
Output
Expected Behavior
Custom header should have been ignored and terraform plan succeeded.
Steps to Reproduce
terraform init
terraform plan
Additional Context
ignored_changes
described in the reference below, but none have worked.lifecycle {ignore_changes = [origin]}
because we still need to modify other properties of the origin (i.e.custom_origin_config
).References
The text was updated successfully, but these errors were encountered: