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

Blob Metadata Not Working #4901

Closed
rrmistry opened this issue Nov 17, 2019 · 4 comments
Closed

Blob Metadata Not Working #4901

rrmistry opened this issue Nov 17, 2019 · 4 comments

Comments

@rrmistry
Copy link

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

Summary

Looks like blob metadata attribute is not working anymore (or as expected)
image

Terraform (and AzureRM Provider) Version

Terraform v0.12.15
+ provider.archive v1.3.0
+ provider.azurerm v1.36.0

Affected Resource(s)

  • azurerm_storage_blob

Terraform Configuration Files

provider "azurerm" {
  # whilst the `version` attribute is optional, we recommend pinning to a given version of the Provider
  version = "~> 1.3"

  # Ref: https://github.com/terraform-providers/terraform-provider-azurerm/issues/4440
  skip_provider_registration = "true"

  subscription_id = var.az_subscription_id
}

# A zip file to package Azure Functions App source
data "archive_file" "package" {
  type        = "zip"
  output_path = "${path.module}/azure.zip"
  source_dir  = "${path.module}/dist"
}

resource "azurerm_storage_account" "default" {
  name                     = var.project_name
  resource_group_name      = var.az_resource_group
  location                 = var.az_region
  account_tier             = "Standard"
  account_replication_type = "LRS"
  tags                     = var.az_tags
}

resource "azurerm_storage_container" "default" {
  name                  = var.project_name
  storage_account_name  = azurerm_storage_account.default.name
  container_access_type = "private"
}

resource "azurerm_storage_blob" "default" {
  name                   = "azure.zip"
  storage_account_name   = azurerm_storage_account.default.name
  storage_container_name = azurerm_storage_container.default.name
  type                   = "block"
  source                 = data.archive_file.package.output_path
  metadata = {
    # Force re-deploy if hash changes
    PACKAGE_HASH = data.archive_file.package.output_base64sha256
  }
}

Debug Output

------
2019/11/17 16:13:11 [TRACE] Executing graph transform *terraform.OrphanResourceCountTransformer
2019/11/17 16:13:11 [TRACE] Completed graph transform *terraform.OrphanResourceCountTransformer (no changes)
2019/11/17 16:13:11 [TRACE] Executing graph transform *terraform.AttachStateTransformer
2019/11/17 16:13:11 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes)
2019/11/17 16:13:11 [TRACE] Executing graph transform *terraform.TargetsTransformer
2019/11/17 16:13:11 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes)
2019/11/17 16:13:11 [TRACE] Executing graph transform *terraform.ReferenceTransformer
2019/11/17 16:13:11 [DEBUG] ReferenceTransformer: "azurerm_storage_container.default" references: []
2019/11/17 16:13:11 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes)
2019/11/17 16:13:11 [TRACE] Executing graph transform *terraform.RootTransformer
2019/11/17 16:13:11 [TRACE] Completed graph transform *terraform.RootTransformer (no changes)
2019/11/17 16:13:11 [TRACE] vertex "azurerm_storage_container.default": entering dynamic subgraph
2019/11/17 16:13:11 [TRACE] dag/walk: updating graph
2019/11/17 16:13:11 [TRACE] dag/walk: added new vertex: "azurerm_storage_container.default"
202019/11/17 16:13:11 [ERROR] <root>: eval: *terraform.EvalDiff, err: MetaData must start with letters or an underscores. Got "PACKAGE_HASH".
2019/11/17 16:13:11 [ERROR] <root>: eval: *terraform.EvalSequence, err: MetaData must start with letters or an underscores. Got "PACKAGE_HASH".
2019/11/17 16:13:11 [TRACE] [walkPlan] Exiting eval tree: azurerm_storage_blob.default
2019/11/17 16:13:11 [TRACE] vertex "azurerm_storage_blob.default": visit complete
2019/11/17 16:13:11 [TRACE] vertex "azurerm_storage_blob.default": dynamic subgraph encountered errors
2019/11/17 16:13:11 [TRACE] vertex "azurerm_storage_blob.default": visit complete
2019/11/17 16:13:11 [TRACE] dag/walk: upstream of "azurerm_function_app.default" errored, so skipping
2019/11/17 16:13:11 [TRACE] dag/walk: upstream of "provider.azurerm (close)" errored, so skipping
2019/11/17 16:13:11 [TRACE] dag/walk: upstream of "output.azurerm_function_app_id" errored, so skipping
2019/11/17 16:13:11 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2019/11/17 16:13:11 [TRACE] dag/walk: upstream of "root" errored, so skipping
2019/11/17 16:13:11 [INFO] backend/local: plan operation completed
2019/11/17 16:13:11 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info

Error: MetaData must start with letters or an underscores. Got "PACKAGE_HASH".2019-11-17T16:13:11.739-0500 [DEBUG] plugin: plugin process exited: path=XXXXXXXXX\.terraform\plugins\windows_amd64\terraform-provider-azurerm_v1.36.0_x4.exe pid=18828
2019-11-17T16:13:11.739-0500 [DEBUG] plugin: plugin exited


  on azurefunction.tf line 27, in resource "azurerm_storage_blob" "default":
  27: resource "azurerm_storage_blob" "default" {

Panic Output

None

Expected Behavior

Detect existing or new value for Azure Blob metadata (without any errors)

Actual Behavior

Errors out when providing metadata map

Steps to Reproduce

  1. terraform plan

Important Factoids

None beyond what is provided above

References

@rrmistry
Copy link
Author

I am using metadata attribute to force Terraform to re-deploy my archive_file to azurerm_storage_blob. I have a workaround using tags on the parent resource azurerm_storage_account, but I would prefer using the metadata attribute.

@rrmistry
Copy link
Author

CC: @Lucretius, @katbyte,

@rrmistry
Copy link
Author

rrmistry commented Dec 7, 2019

Thanks @tombuildsstuff ! I verified that upper case metadata tags will not work as per your comment:
1079afa#r36216441

Even with the perpetual diff I found that changing metadata tag does not update the underlying azurerm_storage_blob resource. Only updates the metadata tag (which is fine).

I found that adding a portion of the file hash to the resource name does refresh the underlying azurerm_storage_blob resource, which meets my needs.

I'll close this issue now.

@rrmistry rrmistry closed this as completed Dec 7, 2019
@ghost
Copy link

ghost commented Jan 6, 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 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 Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants