Trisha Fernandes
Trisha Fernandes

Reputation: 59

GCP Terraform Lifecycle to ignore ssh-keys from instance metadata

I've added the public ssh keys via the console to instance metadata on a GCE instance. But I want to ignore this change in terraform (don't want to add ssh keys in code) by using lifecycle ignore_changes. I've tried using the following but it doesn't work:

  lifecycle {
    ignore_changes = [
      metadata.ssh-keys
    ]
  }

I know you can ignore ALL metadata but I don't want to do that. Just want to ignore ssh keys. What is the exact name I need to use as metadata.ssh-keys doesn't work? - terraform does not seem to recognise that and still has the ssh-keys in the plan.

Upvotes: 2

Views: 1309

Answers (1)

Trisha Fernandes
Trisha Fernandes

Reputation: 59

The correct syntax is

 lifecycle {
    ignore_changes = [metadata["ssh-keys"]]
  }

Upvotes: 3

Related Questions