-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: Possibility to ignore external updates. #48
base: main
Are you sure you want to change the base?
Conversation
Some fields can updated "outside of terraform" i.e. when pushing a docker image tag in a CICD pipeline. This backwards-compatible change allows to explicitly ignore external changes of certain fields (i.e. update_time)
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Ping @prabhu34 |
Hey @prabhu34 can you prioritize reviewing and merging this PR? Thanks. |
(re-opened to re-trigger stuck lint) |
/gcbrun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @oerd!
This is from the lint test:
terraform_validate .
╷
│ Error: Terraform encountered problems during initialisation, including problems
│ with the configuration, described below.
│
│ The Terraform configuration must be valid before initialization so that
│ Terraform can determine which modules and providers need to be installed.
│
│
╵
╷
│ Error: Invalid expression
│
│ on main.tf line 187, in resource "google_artifact_registry_repository" "repo":
│ 187: ignore_changes = var.ignore_changes
│
│ A static list expression is required.
╵
terraform_validate ./examples/gar_docker_repo
╷
│ Error: Invalid expression
│
│ on ../../main.tf line 187, in resource "google_artifact_registry_repository" "repo":
│ 187: ignore_changes = var.ignore_changes
│
│ A static list expression is required.
Seems I was trying to achieve the impossible:
Source: The lifecycle Meta-Argument - Literal values only I will give this some more consideration and eventually close this PR. Hopefully with a workaround. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore changes or rather any meta arguments in Terraform will not support variable substitutions. Suggestions are added.
@@ -182,6 +182,10 @@ resource "google_artifact_registry_repository" "repo" { | |||
} | |||
} | |||
} | |||
|
|||
lifecycle { | |||
ignore_changes = var.ignore_changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore_changes = var.ignore_changes | |
ignore_changes = [ <ADD THE ATTRIBUTES HERE> ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prabhu34 thanks for the quick reply.
Adding update_time
to the ignore_changes
meta argument can be considered a deviation from existing functionality. I would still like to see it merged, under the following motivation:
An Artifact Registry is an "object" container in the same way a GCS Bucket and updating a docker image within an Artifact Registry should not trigger any infrastructure changes in the same way that modifying the contents of a GCS Bucket does not trigger any infrastructure changes.
Is this motivation adequate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation seems good as it mentions about changes to the object itself on GCS or Artifact Registry, rather than update time metadata info. Go ahead with the suggestion and we can update later as needed.
variable "ignore_changes" { | ||
type = list(string) | ||
description = "List of resource attributes to ignore changes for" | ||
default = [] | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable "ignore_changes" { | |
type = list(string) | |
description = "List of resource attributes to ignore changes for" | |
default = [] | |
} |
Some fields can be updated "outside of terraform" i.e. when pushing a docker image tag in a CICD pipeline. This backwards-compatible change allows to explicitly ignore external changes of certain fields (i.e. update_time)
fixes #47