-
Notifications
You must be signed in to change notification settings - Fork 988
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
Resource import of kubernetes_namespace not working #2146
Comments
Hello @darlinchen! Could you give me an example of what's in your namespace variable? I was able to import successfully using this tfconfig and the tf import command below variable "namespaces" {
default = {"namespace"= "terraform-test"}
}
resource "kubernetes_namespace" "this" {
for_each = var.namespaces
metadata {
name = each.value
}
}
The output should look like this: mau@mau-JKDT676NCP ~/Dev/Scratch/import_namespaces terraform import 'kubernetes_namespace.this["namespace"]' terraform-test
kubernetes_namespace.this["namespace"]: Importing from ID "terraform-test"...
kubernetes_namespace.this["namespace"]: Import prepared!
Prepared kubernetes_namespace for import
kubernetes_namespace.this["namespace"]: Refreshing state... [id=terraform-test]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform. |
I am also seeing this error when using a list of string to define my namespace names
I am using terragrunt so in my input values I have a list of names however I need to import a namespace that was already created.
Running the import comes back as successful but not seeing the namespace in the state file
terragrunt console output
|
Since for_each works on a set of strings, the correct syntax for the import command in this case would be:
|
Thank you, it works when using |
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you! |
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
Steps to Reproduce
terraform import 'module.modulename.kubernetes_namespace.this["namespace"]' namespace
Expected Behavior
The resource was successful imported not only the command output
Actual Behavior
Terraform said import was successful but the resource is not in the terraform state
Important Factoids
Kubernetes Cluster running in Azure
References
Community Note
The text was updated successfully, but these errors were encountered: