Skip to content
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

Dependency issue between instance_template and instance_group_manager? #1601

Closed
synhershko opened this issue Jun 6, 2018 · 4 comments
Closed
Labels

Comments

@synhershko
Copy link

It seems to be impossible to update an instance template without hitting the following error on apply:

google_compute_instance_template.elasticsearch2-master: Error deleting instance template: googleapi: Error 400: The instance_template resource 'projects/myproject-119711/global/instanceTemplates/terraform-20180606093020757400000002' is already being used by 'projects/myproject-119711/zones/europe-west1-b/instanceGroupManagers/elasticsearch2-master', resourceInUseByAnotherResource

Whether or not I set the instance_template name myself, every attempt to make a change fails with this error, likely because of a dependency issue with the instance_group_manager, or a bug relating to finding and updating that resource?

Using latest terraform and gcp provider

@rosbo
Copy link
Contributor

rosbo commented Jun 6, 2018

Hi,

You can use the create_before_destroy feature for this.

Update your instance template config as follow:

resource "google_compute_instance_template" "test-it" {
  # Don't use the name field since the newly created template can't have the same name
  name_prefix = "test-it"
  ...
  lifecycle {
    create_before_destroy = true
  }
}

With this config, the proper order will be respected:

google_compute_instance_template.test-it: Still creating... (10s elapsed)
google_compute_instance_template.test-it: Creation complete after 12s (ID: test-it20180606175118068900000001)
google_compute_instance_group_manager.test-igm: Modifying... (ID: test-igm)
  instance_template: "https://www.googleapis.com/compute/v1/projects/[redacted]/global/instanceTemplates/test-it" => "https://www.googleapis.com/compute/beta/projects/[redacted]/global/instanceTemplates/test-it20180606175118068900000001"
google_compute_instance_group_manager.test-igm: Still modifying... (ID: test-igm, 10s elapsed)
google_compute_instance_group_manager.test-igm: Still modifying... (ID: test-igm, 20s elapsed)
google_compute_instance_group_manager.test-igm: Modifications complete after 22s (ID: test-igm)
google_compute_instance_template.test-it.deposed: Destroying... (ID: test-it)
google_compute_instance_template.test-it (deposed #0): Still destroying... (ID: test-it, 10s elapsed)
google_compute_instance_template.test-it.deposed: Destruction complete after 11s

Apply complete! Resources: 1 added, 1 changed, 1 destroyed.

Let me know if that solves your problem

@rosbo rosbo self-assigned this Jun 6, 2018
@rosbo
Copy link
Contributor

rosbo commented Jun 7, 2018

I closed the issue because I am fairly certain this should solve your issue. However, if it doesn't, please reopen the issue.

Thank you

@rosbo rosbo closed this as completed Jun 7, 2018
@rosbo rosbo added the question label Jun 7, 2018
@synhershko
Copy link
Author

It did, thanks!

@ghost
Copy link

ghost commented Nov 18, 2018

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost unassigned rosbo Nov 18, 2018
@ghost ghost locked and limited conversation to collaborators Nov 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants