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

azurerm_storage_table was idempotent in 0.11.3 but supposedly not in 0.11.4 #17660

Closed
RichardSlater opened this issue Mar 21, 2018 · 14 comments
Closed
Labels
waiting-response An issue/pull request is waiting for a response from the community

Comments

@RichardSlater
Copy link

Terraform Version

Terraform v0.11.4
+ provider.azurerm v1.3.0

Terraform Configuration Files

MCVE:

terraform {
  backend "azurerm" {
    resource_group_name  = "chatbot-170-tfstate-rg"
    storage_account_name = "chatbot170tfstatestor"
    container_name       = "tfstate"
    key                  = "terraform.tfstate"
  }
}

resource "azurerm_resource_group" "dev" {
  name     = "amido-uks-cb170-rg-bot-dev"
  location = "UK South"

resource "azurerm_storage_account" "dev" {
  name                     = "amidoukscb170"
  resource_group_name      = "${azurerm_resource_group.dev.name}"
  location                 = "${azurerm_resource_group.dev.location}"
  account_tier             = "Standard"
  account_replication_type = "GRS"
  enable_blob_encryption   = "true"

  tags {
    environment = "Development"
  }
}

resource "azurerm_storage_table" "dev" {
  name                 = "development"
  resource_group_name  = "${azurerm_resource_group.dev.name}"
  storage_account_name = "${azurerm_storage_account.dev.name}"
}

Debug Output

$env:TF_LOG="trace"
tf apply --auto-approve 2>&1 | Out-File .\tf-log.log

Log File
Encrypted for Hashicorp Security and signed with my Public Key

Expected Behavior

terraform apply completes as expected

Actual Behavior

Error: Error applying plan:

1 error(s) occurred:

* module.dev.module.uksouth.azurerm_storage_table.dev: 1 error(s) occurred:

* azurerm_storage_table.dev: Error creating table "development" in storage account "amidoukscb170": storage: service returned error: StatusCode=409, ErrorCode=TableAlreadyExists, ErrorMessage=The table specified already exists.
RequestId:4fb86a90-a002-000a-3928-c11a35000000
Time:2018-03-21T15:23:31.1865693Z, RequestInitiated=Wed, 21 Mar 2018 15:23:30 GMT, RequestId=4fb86a90-a002-000a-3928-c11a35000000, API Version=2016-05-31, QueryParameterName=, QueryParameterValue=

Steps to Reproduce

  1. terraform init
  2. terraform get
  3. terraform apply

Additional Context

Confirmed both on Windows (Localhost) and Ubuntu 14 (Shippable). Slightly irritatingly now I have upgraded to 0.11.4 I can't downgrade my state file to 0.11.3.

References

None observed.

@jbardin
Copy link
Member

jbardin commented Mar 21, 2018

Hi @RichardSlater,

Sorry you're having an issue here.
Are you certain that the only difference is terraform 0.11.4 vs 0.11.3, or was the azure provider updated as well?

@jbardin jbardin added the waiting-response An issue/pull request is waiting for a response from the community label Mar 21, 2018
@RichardSlater
Copy link
Author

Let me check, I'm going to have to kill off my state and try the old version.

@jbardin
Copy link
Member

jbardin commented Mar 21, 2018

Thanks.
For the record, I'm not aware of any provider resources that allow creation when they already exist. This almost always requires explicitly importing a resource into the state, so that may have been considered a bug in the azurerm_storage_table resource.

@RichardSlater
Copy link
Author

Terraform v0.11.3
+ provider.azurerm v1.3.0

Looks to me like the azurerm provider is the same across both Terraform-v0.11.3 and Terraform-v0.11.4.

@RichardSlater
Copy link
Author

RichardSlater commented Mar 21, 2018

I assume this is related: hashicorp/terraform-provider-azurerm#1003

It's possible that I have incorrectly attributed this to Terraform rather than the azurerm provider. Interesting that it only appears to have surfaced with the upgrade from v0.11.3 to v0.11.4.

RichardSlater added a commit to RichardSlater/chatbot-170-infrastructure that referenced this issue Mar 21, 2018
@jbardin
Copy link
Member

jbardin commented Mar 21, 2018

Hi @RichardSlater,

Running your config directly doesn't reproduce the issue for me. If you're saying that the azurerm_storage_table already exists before applying the configuration, then this is the expected failure and I'm not sure how it would have worked previously.

@RichardSlater
Copy link
Author

That's strange let me extract it out to a separate repository, I've been able to repro it consistently. Seems I'm not the only one, given the final comment in hashicorp/terraform-provider-azurerm#1003.

@RichardSlater
Copy link
Author

Terraform 0.11.3

Prerequisites: Terraform 0.11.3 installed

> git clone git@github.com:RichardSlater/terraform-0.11.4-azurerm-idempotence.git
> cd terraform-0.11.4-azurerm-idempotence
> git checkout 0.11.3
> terraform init
> terraform apply
< Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
> terraform apply
< Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
> terraform destroy
< Destroy complete! Resources: 3 destroyed.

Terraform 0.11.4

Prerequisites: Terraform 0.11.4 installed

> git clone git@github.com:RichardSlater/terraform-0.11.4-azurerm-idempotence.git
> cd terraform-0.11.4-azurerm-idempotence
> git checkout 0.11.4
> terraform init
> terraform apply
< Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
> terraform apply
< Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
> terraform destroy
< Destroy complete! Resources: 3 destroyed.

Well that's odd... going to add Key Vault back in to see if that has an effect.

@RichardSlater
Copy link
Author

Yeah, no idea why I can't reproduce it within the test repo, I'll try the original repo tomorrow.

@RichardSlater
Copy link
Author

Having deleted the state and all of the resources in my diagnostic steps I can no longer reproduce this issue, have upgraded to Terraform 0.11.5 and everything is running well.

@pixelicous
Copy link

Im having the same problem, different state file every time i launch, even removed the .terraform folder..

@RichardSlater
Copy link
Author

Are you using remote state or pure local state?

@pixelicous
Copy link

pixelicous commented Mar 23, 2018

@RichardSlater im using backends and workspaces

@ghost
Copy link

ghost commented Apr 4, 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 Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

No branches or pull requests

3 participants