-
Notifications
You must be signed in to change notification settings - Fork 286
chore: add hcledit for tf resource fixup #843
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
Conversation
fc3e307 to
f63322f
Compare
a3c8b80 to
c22a1cd
Compare
build/int.cloudbuild.yaml
Outdated
| go install github.com/minamijoyo/[email protected] | ||
| # Add `deletion_protection = false` to google_container_cluste.default resources | ||
| find . -name "*.tf" -print | xargs -t -I {} $$GOPATH/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection 'false' -u -f {} || true |
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.
This outputs the command for every tf file in the repo. For this resource, is it more useful to stick to gke/? Could it also report what was changed?
After this change is merged, it would also be useful to add this for google_sql_database_instance, so in it's current form, there would be a lot of log noise if this line is copied for other settings.
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.
Also: this will not affect the resources in gke/standard/zonal/no-channel-to-release-channel/main.tf (multiple instances declared with custom names),
gke/standard/regional/binary-authorization/main.tf or
gke/standard/regional/ray/main.tf (they should use 'default', but don't.)
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.
gke/
Yes, I've rescoped it to ./gke. Currently the only option appears to log if it doesn't succeed (for example the attribute is already defined).
google_sql_database_instance
Yup, we should just need to add a line similar to #76 for google_sql_database_instance
this will not affect the resources in
Correct, I noticed some google_container_cluster are using non-standard names and will address in a follow-up PR as I need to validate options to address (particularly the multiple instances examples). Unfortunately hcledit doesn't support wildcard for resource names.
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.
Here is the updated behavior with example of 2 "error":
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/quickstart/multitenant/main.tf
Step #1 - "resource specific fixups": attribute already exists: resource.google_container_cluster.default.deletion_protection
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/quickstart/autopilot/cluster.tf
Step #1 - "resource specific fixups": attribute already exists: resource.google_container_cluster.default.deletion_protection
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/quickstart/autopilot/app.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/enterprise/mesh/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/enterprise/policycontroller/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/enterprise/config_sync/git/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/enterprise/config_sync/oci/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/enterprise/enable/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/mesh/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/labels/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/policycontroller/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/iap/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/basic/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/release_channel/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/reservation/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/config_sync/git/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/config_sync/oci/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/autopilot/tag/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/node_image/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/secondary-boot-disk/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/gpu/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/arm/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/single-zone/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/multi-zone/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/no-channel-to-release-channel/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/zonal/reservation/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/node_pool/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/hpa-logs/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/ray/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/labels/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/node_system_config/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/gemma-tgi/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/single-zone/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/windows/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/loadbalancer/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/binary-authorization/main.tf
Step #1 - "resource specific fixups": /go/bin/hcledit attribute append resource.google_container_cluster.default.deletion_protection false -u -f ./gke/standard/regional/multi-zone/main.tf
glasnt
left a comment
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.
Approval, comments can be addressed in future PRs to unblock
Description
Fixes b/401371689
deletion_protection = falsefor non-quickstart google_container_cluster.defaultChecklist
Readiness
Style
guide
Testing
I have performed tests described in the Contributing guide:
terraform applyterraform fmtcheckIntended location
Yes, this sample will be (or already is) included on cloud.google.com
Location(s):
No, this sample won't be included on cloud.google.com
Reason:
API enablement
Review