terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

Unable to show resources with self_link in metadata

Open joe-a-t opened this issue 4 years ago • 11 comments

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v0.15.3
Kubernetes provider version: v2.3.1

Affected Resource(s)

  • kubernetes_config_map
  • kubernetes_namespace
  • Almost certainly others as well

Terraform Configuration Files

resource "kubernetes_config_map" "example" {
  metadata {
    name = "my-config"
  }
}

Debug Output

Panic Output

Steps to Reproduce

  1. Create a kubernetes_config_map with v2.3.0 (or earlier) of the Kubernetes provider
  2. Run terraform state show kubernetes_config_map.example to verify it works
  3. Upgrade the Kubernetes provider to v2.3.1
  4. terraform state show kubernetes_config_map.example will no longer work with unsupported attribute "self_link" error message

Expected Behavior

The resource should have been output.

Actual Behavior

unsupported attribute "self_link" error message

Important Factoids

This also causes errors if you try to open terraform console in any affected directories.

References

It appears to stem from https://github.com/hashicorp/terraform-provider-kubernetes/pull/1294 cc @dak1n1

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

joe-a-t avatar Jun 08 '21 01:06 joe-a-t

Unrelated but FYI I was just notified issue_triage failed with

Error: Unable to resolve action `github/issue-labeler@v2`, unable to find version `v2`

joe-a-t avatar Jun 08 '21 01:06 joe-a-t

Looks like we need a StateUpgrader to delete the self_link attribute from state for it to work with the terraform state command. I was able to reproduce and this doesn't seem to be affecting plan or apply.

A workaround here is run terraform refresh which will fix the state.

jrhouston avatar Jun 08 '21 14:06 jrhouston

Unrelated but FYI I was just notified issue_triage failed with

Error: Unable to resolve action `github/issue-labeler@v2`, unable to find version `v2`

Thanks for letting us know! I added some fixes to my Github Workflow PR that's in progress here: https://github.com/hashicorp/terraform-provider-kubernetes/pull/1300

dak1n1 avatar Jun 09 '21 21:06 dak1n1

✗ tfp
╷
│ Error: Unsupported attribute
│
│   on ../../modules/cluster_vault/kms.tf line 17, in resource "google_kms_crypto_key" "vault_init":
│   17:   key_ring        = google_kms_key_ring.vault.self_link
│
│ This object has no argument, nested block, or exported attribute named "self_link".

Ive already tried tf refresh but no use.

Any idea how I can fix this ?

tf version
Terraform v1.0.10
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.0.0
+ provider registry.terraform.io/hashicorp/google-beta v4.0.0

jeunii avatar Nov 08 '21 19:11 jeunii

Ok so i got hold of https://github.com/hashicorp/terraform-provider-google/pull/10424/files !

Found the fix. Replaced self_link with id in the code

jeunii avatar Nov 08 '21 19:11 jeunii

Any solution for this? I'm getting this error after upgrading from 2.0.0 to 2.78:

| Error decoding "module.az-devops-namespace_setup.kubernetes_secret.pull_secret[0]" from previous state:
│ unsupported attribute "self_link"

MeNsaaH avatar Mar 24 '22 23:03 MeNsaaH

@MeNsaaH similar issue here, version 2.11.0. Were you able to resolve it?

tobamaestro avatar Jun 06 '22 10:06 tobamaestro

@tobamaestro no. I had to downgrade

MeNsaaH avatar Jun 06 '22 10:06 MeNsaaH

@MeNsaaH Thanks for quick reply! Did you try running terraform refresh maybe before downgrading?

tobamaestro avatar Jun 06 '22 14:06 tobamaestro

@tobamaestro I'm not sure I did. I think I deleted my lock file, ran init then destroyed

MeNsaaH avatar Jun 06 '22 18:06 MeNsaaH

I encountered this issue, refreshing didn't help. I resolved it using terraform state rm to delete the offending resources, and then I re-imported them. Because I imported them using the latest Kubernetes provider version, it fixed the bad attributes.

mbyio avatar Sep 07 '22 21:09 mbyio

Happening with me on version 2.13.0.

Terraform will perform the following actions:

  # module.nexus_admin_user_password.kubernetes_secret.user_password will be updated in-place
  ~ resource "kubernetes_secret" "user_password" {
      ~ data      = (sensitive value)
        id        = "studio-ci/nexus-admin"
        # (2 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

abdullahkhawer avatar Jan 04 '23 11:01 abdullahkhawer

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!

github-actions[bot] avatar Jan 05 '24 00:01 github-actions[bot]