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

When lifecycle has create_before_destroy, we can ask the provider ahead-of-time if naming conflicts will block create-before-destroy #127

Closed
cjcjameson opened this issue Dec 12, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@cjcjameson
Copy link

Current Terraform Version

11.10

Use-cases

A resource is labelled create_before_destroy

A attribute of that resource requires recreating that resource to be applied

But the "name" of that resource in the IaaS doesn't change, and there will be a conflict from the IaaS when trying to create before destroying.

hashicorp/terraform-provider-aws#6812

You end up waiting a long time, and getting a failure for a naming conflict. You know that there's a naming conflict. Maybe you temporarily don't care about create_before_destroy, or maybe you want to be alerted specifically that's why there's a conflict.

Attempted Solutions

The workaround is to temporarily not create-before-destroy, or manually destroy and then recreate with terraform...

Proposal

I think providers would need to add a boolean to the schema elements, something like must_change_to_create_before_destroy

https://github.com/terraform-providers/terraform-provider-aws/blob/d609b1f599625d0b1d0a8f219f8bbf37e16a1ceb/aws/resource_aws_security_group.go#L41-L48

References

hashicorp/terraform-provider-aws#6812

@hashibot hashibot transferred this issue from hashicorp/terraform Sep 26, 2019
@hashibot hashibot added the enhancement New feature or request label Oct 2, 2019
@radeksimko
Copy link
Member

Hi @cjcjameson
This is a good idea, but Terraform currently has no way of identifying unique resources in general, which is an important prerequisite for such feature.

This feature is tracked under #224 and I expect that reporting ID conflicts in planning stage would be one of the main use cases. I will close this issue as a duplicate of #224 which will also link it from there, so we won't loose the important context, but it will allow us to keep relevant discussion in one place.

You also mentioned that in AWS specifically you had to wait until seeing a relevant error. This may be because the underlying API isn't designed to handle certain situations - e.g. it exposes a single endpoint for both creating and updating the resource, i.e. it does not error out when a resource of the same name already exists.

Relatedly #101 describes how we might allow providers to perform early "enhanced" validation (such as checking whether name of a resource is available) in the future.

@ghost
Copy link

ghost commented Mar 30, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants