Tanguy_B
Tanguy_B

Reputation: 31

Order an Azure app service certificate with terraform

I would like to order an App Service Certificate and store it in a keyvault using terraform. I found this azurerm_app_service_certificate_order that can order the certificate, however the certificate is in hold until I manually go to the gui and add it to a keyvault. Can this step be automated with terraform ?

Thanks in advance!

Upvotes: 3

Views: 1461

Answers (1)

adp
adp

Reputation: 1271

You can use azurerm_key_vault_certificate resource to add a certificate having the path certificate-to-import.pfx as shown in the example below:

resource "azurerm_key_vault_certificate" "example" {
  name         = "imported-cert"
  key_vault_id = azurerm_key_vault.example.id

  certificate {
    contents = filebase64("certificate-to-import.pfx")
    password = ""
  }

  certificate_policy {
    issuer_parameters {
      name = "Self"
    }

    key_properties {
      exportable = true
      key_size   = 2048
      key_type   = "RSA"
      reuse_key  = false
    }

    secret_properties {
      content_type = "application/x-pkcs12"
    }
  }
}

Upvotes: 0

Related Questions