Skip to content

Instantly share code, notes, and snippets.

@ilmax
Last active November 25, 2022 15:41
Show Gist options
  • Select an option

  • Save ilmax/11817b6c0e00df9237ae54e2c5fcef84 to your computer and use it in GitHub Desktop.

Select an option

Save ilmax/11817b6c0e00df9237ae54e2c5fcef84 to your computer and use it in GitHub Desktop.
azapi terraform provider configuration
resource "azapi_resource" "aca-test-environment" {
name = "aca-test-environment"
type = "Microsoft.App/managedEnvironments@2022-03-01"
location = var.location
parent_id = azurerm_resource_group.aca-test-rg.id
body = jsonencode({
properties = {
appLogsConfiguration = {
destination = "log-analytics"
logAnalyticsConfiguration = {
customerId = azurerm_log_analytics_workspace.aca-test-ws.workspace_id
sharedKey = azurerm_log_analytics_workspace.aca-test-ws.primary_shared_key
}
}
}
})
}
resource "azapi_resource" "producer_container_app" {
name = "producer-containerapp"
location = var.location
parent_id = azurerm_resource_group.aca-test-rg.id
type = "Microsoft.App/containerApps@2022-03-01"
body = jsonencode({
properties = {
managedEnvironmentId = azapi_resource.aca-test-environment.id
configuration = {
ingress = {
targetPort = 80
external = true
},
registries = [
{
server = azurerm_container_registry.aca-test-registry.login_server
username = azurerm_container_registry.aca-test-registry.admin_username
passwordSecretRef = "registry-password"
}
],
secrets : [
{
name = "registry-password"
# Todo: Container apps does not yet support Managed Identity connection to ACR
value = azurerm_container_registry.aca-test-registry.admin_password
}
]
},
template = {
containers = [
{
image = "${azurerm_container_registry.aca-test-registry.login_server}/${var.producer_image_name}:latest"
name = "producer",
env : [
{
"name" : "EnvVariable",
"value" : "Value"
}
]
}
]
}
}
})
# This seems to be important for the private registry to work(?)
ignore_missing_property = true
response_export_values = ["properties.configuration.ingress"]
}
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.7.0"
}
azapi = {
source = "Azure/azapi"
}
}
}
@rolandihms
Copy link

Yeah @ilmax I am very impressed with ACA product offering.

Take care!

@rolandihms
Copy link

Finally got back full control of the infra 💥. complete destroy and fresh deploy did the trick and sorted the ACR issue that led me here in the first place.🤦‍♂️

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment