DEV Community 👩‍💻👨‍💻

Cover image for Update Content with Terraform

Posted on

Update Content with Terraform

Photo by Markus Winkler on Unsplash


We are using Terraform to deploy infrastructure. But we are using it too, to deploy content (such as secrets, files etc ...).

In order to update such content, we have to specify extra data per type of content.

Key Vault Secrets

In order to update content for Azure Key Vault secrets, we can use tags, filed using current date with timestamp.


resource "azurerm_key_vault_secret" "secret_sample" {
  name      = "secret_sample"
  value     = "example"
  key_vault_id =
  tags = {
    time        = timestamp()
Enter fullscreen mode Exit fullscreen mode

Blob / Files

In order to update content for blob / files, we can use content_md5, filed using function filemd5.


resource "azurerm_storage_blob" "source_files" {
  for_each = fileset("${path.module}/source_files", "/*.png")
  name                   = each.value
  storage_account_name   =
  storage_container_name = "test"
  type                   = "Block"
  source                 = "source_files/${each.value}"
  content_md5            = filemd5("source_files/${each.value}")
Enter fullscreen mode Exit fullscreen mode

Hope this helps !

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.