Home > front end >  Key Vault Secret Time Expiry
Key Vault Secret Time Expiry

Time:11-08

I am trying to set an expiry date that is dynamic in a Terraform template. The idea is to get current date and add 6 months to that date and use that as the expiry date for the secret, however I am struggling to do so.

I am trying to achieve this using the time_offset and timestamp() but it isn't working and I get the following error.

main.tf

resource "time_offset" "expiry_date" {
  offset_months = 6
}

resource "azurerm_key_vault_secret" "local_admin_pwd" {
    name = "LocalAdminPassword"
    value = random_password.pwd.result
    key_vault_id = azurerm_key_vault.keyvault.id
    expiration_date = timestamp(time_offset.expiry_date.rfc3339)
}

error

│ Error: Too many function arguments
│ 
│   on key_vault/main.tf line 56, in resource "azurerm_key_vault_secret" "local_admin_pwd":
│   56:     expiration_date = timestamp(time_offset.expiry_date.rfc3339)
│     ├────────────────
│     │ while calling timestamp()
│ 
│ Function "timestamp" expects only 0 argument(s).

CodePudding user response:

The built-in timestamp function does not expect any arguments:

Function "timestamp" expects only 0 argument(s).

The expiration_date argument should get the value from the attribute provided by the time_offset resource only:

expiration_date = time_offset.expiry_date.rfc3339
  • Related