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

Hey @ilmax,

Thanks for the feedback, info and links. Will check out the sample repo. It looks like the containers are actually deployed but terraform times out somewhere and responds with "Operation Expired". Looks like its an issue on the Azure Rest API. AzApi.

 --------------------------------------------------------------------------------
│ RESPONSE 200: 200 OK
│ ERROR CODE: ContainerAppOperationError
│ --------------------------------------------------------------------------------

 {
│   "id": "/subscriptions/xxxxxxx/providers/Microsoft.App/locations/southafricanorth/containerappOperationStatuses/xxxxxxxxxx",
│   "name": "ec9f023d-9014-42a1-b224-3d87f8f91480",
│   "status": "Failed",
│   "error": {
│     "error": {
│       "code": "ContainerAppOperationError",
│       "message": "Failed to provision revision for container app 'msgraph-api'. Error details: Operation expired."
│     },
│     "code": "ContainerAppOperationError",
│     "message": "Failed to provision revision for container app 'msgraph-api'. Error details: Operation expired."
│   },
│   "startTime": "2022-11-25T12:56:08.3368327"
│ }

I will destroy and start fresh to see if this is reproduced.

Eagerly waiting for the next version bump.

Thanks again, have a great day...
Cheers

@ilmax
Copy link
Author

ilmax commented Nov 25, 2022

Hey @rolandihms it may be related to this let's hope we can get some fixes there because ACA for me is an amazing product!

Cheers

@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