DEV Community

Cover image for Update Content with Terraform
Antoine
Antoine

Posted on

2 2

Update Content with Terraform

Photo by Markus Winkler on Unsplash

Introduction

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.

example:

resource "azurerm_key_vault_secret" "secret_sample" {
  name      = "secret_sample"
  value     = "example"
  key_vault_id = azurerm_key_vault.mykeyvault.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.

example:

resource "azurerm_storage_blob" "source_files" {
  for_each = fileset("${path.module}/source_files", "/*.png")
  name                   = each.value
  storage_account_name   = azurerm_storage_account.storageaccount.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 !

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay