Skip to content

When not using for_each, name or namespace changes fail during dry-run #132

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

Closed
pst opened this issue Sep 29, 2021 · 0 comments
Closed

When not using for_each, name or namespace changes fail during dry-run #132

pst opened this issue Sep 29, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@pst
Copy link
Member

pst commented Sep 29, 2021

Name change

╷
│ Error: github.com/kbst/terraform-provider-kustomize/kustomize.kustomizationResourceDiff: apiVersion: "v1", kind: "ResourceQuota", namespace: "default" name: "default": patch failed 'application/strategic-merge-patch+json': the name of the object (default2) does not match the name on the URL (default)
│ 
│   with kustomization_resource.current,
│   on manifest.tf line 9, in resource "kustomization_resource" "current":
│    9: resource "kustomization_resource" "current" {
│ 
╵

Namespace change

╷
│ Error: github.com/kbst/terraform-provider-kustomize/kustomize.kustomizationResourceDiff: apiVersion: "v1", kind: "ResourceQuota", namespace: "default" name: "default": patch failed 'application/strategic-merge-patch+json': the namespace of the object (default2) does not match the namespace on the request (default)
│ 
│   with kustomization_resource.current,
│   on manifest.tf line 9, in resource "kustomization_resource" "current":
│    9: resource "kustomization_resource" "current" {
│ 
╵

When using for_each, as is the default, name and namespace are part of the ID in the Terraform state. So a change to either, will out of the box trigger a destroy and recreate apply in Terraform. However, when not using for_each to avoid its limitations, a name or namespace change does not change the ID in the Terraform state. Hence, Terraform will run the diff function for the resource. But the dry-run used in the diff function will fail with the above errors from the K8s API.

@pst pst added the bug Something isn't working label Sep 29, 2021
@pst pst closed this as completed in d03036e Sep 29, 2021
pst added a commit that referenced this issue Sep 29, 2021
ForceNew when name or namespace change without state ID change fix #132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant