I’m using Terraform to create the infrastructure for an Azure Container Apps based project.
I have set up Azure Key Vault and AppConfiguration with a combination of config items that reference Key Vault values, and some that are manually defined (non-sensitive).
I am trying to create an Azure Container App instance whose secrets reference the values used by AppConfiguration, but have so far been unable to find a way to do this – using the app_configuration_keys data source gives me the items but the values are just url representations, and when I try to populate the container app secrets with this, those same urls are used.
Does anyone know if it’s possible to do this? Previously, I was using Key Vault without AppConfiguration and was able to populate the secrets by passing in a reference to the key vault items in my CDKTF but I am now looking to add more environments which will have different sources of config, so AppConfiguration seems a better fit.
Any advice appreciated.
Thanks
2
Answers
From Use App Configuration references for App Service and Azure Functions:
An App Configuration reference is of the form:
For example:
Or, as an alternative, without any
Label
:Terraform doesn’t expand KeyVault connection strings like App Service does. There is specific code which initialises on startup of an App Service, which makes the Graph API calls to retrieve the secrets referenced inside the
{}
braces.TF knows nothing about this. But it can retrieve the secrets from KeyVault if you extract the necessary parts from the KV URI.
You are already extracting the app configuration keys, so you can adapt the below example to suit your requirements.
You’ll need to change
secret_uri =
to pass in the value from app_configuration_keys output.