patternterraformMinor
Skip terraform resource if it exists
Viewed 0 times
existsskipresourceterraform
Problem
I'm Getting an error creating a secret because it was created manually.
Is there any way to tell Terraform to skip creating a resource if it already exists ?
Error: error creating Secrets Manager Secret: ResourceExistsException: The operation failed because the secret already exists.Is there any way to tell Terraform to skip creating a resource if it already exists ?
Solution
after terraform 0.12 we have ways to control it using lifecycle we can simply skip resource by setting up lifecycle
Here is the link of bug
https://github.com/hashicorp/terraform/pull/2525
resource "aws_instance" "web" {
ami = "foo"
lifecycle {
ignore_changes = ["ami"]
}
}Here is the link of bug
https://github.com/hashicorp/terraform/pull/2525
Code Snippets
resource "aws_instance" "web" {
ami = "foo"
lifecycle {
ignore_changes = ["ami"]
}
}Context
StackExchange DevOps Q#16888, answer score: 2
Revisions (0)
No revisions yet.