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

Apply updates existing infrastructure, even if it's not in the state. #1946

Closed
craigmonson opened this issue Sep 19, 2018 · 2 comments
Closed
Labels

Comments

@craigmonson
Copy link

craigmonson commented Sep 19, 2018

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.8

  • provider.azurerm v1.15.0

Affected Resource(s)

That I know of

  • azurerm_resource_group
  • azurerm_public_ip

Terraform Configuration Files

N/A

Debug Output

N/A (Sorry, it's impossible for me to get as I'm not going to duplicate the apply.)

Panic Output

N/A - Didn't panic

Expected Behavior

Expecting terraform to error because the infrastructure already exists, and to not move forward until it's imported.

Actual Behavior

It automatically imported those resources, and applied changes to them (in the form of tags as far as I can tell).

Steps to Reproduce

  1. create a template that has an already existing azurerm_resource_group and do something minor, like add a tag.
  2. plan
  3. apply
  4. Take a look at the resource groups tags, and see it's been altered, note the resource in the state / do a terraform show

Important Factoids

References

@tombuildsstuff
Copy link
Contributor

hi @craigmonson

Thanks for opening this issue :)

Terraform will set ensure the fields set on any resources match the values set in the state - such that any changes not specified in Terraform (e.g. extra tags) will be removed in favour of the expected configuration.

There's currently a bug in the AzureRM Provider (due to the nature of the Azure API's being Upserts, rather than separate Create/Update methods as in other API's) where resources don't have to exist in the State prior to being used by Terraform (such that Terraform will silently update them). We've got a fix for this coming in #1746 - where Terraform will now require that resources which already exist are imported into the state (via terraform import).

Would you be able to take a look and see if importing the resource in the state works for you? Since there's a fix for this coming in #1746 I'm going to close this issue in favour of that one for the moment.

Thanks!

@ghost
Copy link

ghost commented Mar 6, 2019

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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 6, 2019
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