`resource "azurerm_container_app_job" "container_app_job" {
name = "xxx-${var.location_short_name}-${var.environment}"
location = var.location
resource_group_name = var.resource_group_name
container_app_environment_id = var.ca_environment
replica_timeout_in_seconds = 10
replica_retry_limit = 10
manual_trigger_config {
parallelism = 4
replica_completion_count = 1
}
secrets = [
{
name = "container-registry-password"
value = var.registry_credentials.registry_key
}
]
template {
container {
name = "app-container"
image = "${var.registry_credentials.registry_server_url}/${var.image_name}:${var.environment}"
env {
name = "REGISTRY_USERNAME"
value = var.registry_credentials.registry_username
}
env {
name = "REGISTRY_SERVER"
value = var.registry_credentials.registry_server_url
}
env {
name = "REGISTRY_PASSWORD"
secret_ref = "container-registry-password"
}
readiness_probe {
transport = "HTTP"
port = 5000
}
liveness_probe {
transport = "HTTP"
port = 5000
path = "/health"
header {
name = "Cache-Control"
value = "no-cache"
}
initial_delay = 5
interval_seconds = 20
timeout = 2
failure_count_threshold = 1
}
startup_probe {
transport = "TCP"
port = 5000
}
cpu = 0.5
memory = "1Gi"
}
}
}
`
Error:
│ Error: Unsupported block type │ │ on container-app-jobs/main.tf line 57, in resource "azurerm_container_app_job" "container_app_job": │ 57: registry *** │ │ Blocks of type "registry" are not expected here. ╵ ╷ │ Error: Unsupported block type │ │ on container-app-jobs/main.tf line 62, in resource "azurerm_container_app_job" "container_app_job": │ 62: secret *** │ │ Blocks of type "secret" are not expected here. Did you mean "secrets"?
Can someone help in this context?
Unsupported 'registry' and 'secret' Block Types in Terraform Configuration
Thanks Rui Jarimba for pointing in the right direction. Issue seems to be the version used "3.104.0" as per the latest terraform registry the the provider version as of today is "4.13.0".
As per the documentation Where it supports "registry" & "secret" not "secrets" as per error description and comments it seems you're using the key work "secret" inside the configuration with wrong provider version. demo configuration using latest version:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.13.0"
}
}
}
provider "azurerm" {
features {}
}
.
.
.
resource "azurerm_container_app_job" "container_app_job" {
name = "testsam-${var.location_short_name}-${var.environment}"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
container_app_environment_id = azurerm_container_app_environment.ca_env.id
replica_timeout_in_seconds = 10
replica_retry_limit = 10
manual_trigger_config {
parallelism = 4
replica_completion_count = 1
}
template {
container {
name = "app-container"
image = "${var.registry_credentials.registry_server_url}/${var.image_name}:${var.environment}"
env {
name = "REGISTRY_USERNAME"
value = var.registry_credentials.registry_username
}
env {
name = "REGISTRY_SERVER"
value = var.registry_credentials.registry_server_url
}
env {
name = "REGISTRY_PASSWORD"
secret_name = "container-registry-password"
}
readiness_probe {
transport = "HTTP"
port = 5000
}
liveness_probe {
transport = "HTTP"
port = 5000
path = "/health"
header {
name = "Cache-Control"
value = "no-cache"
}
initial_delay = 5
interval_seconds = 20
timeout = 2
failure_count_threshold = 1
}
startup_probe {
transport = "TCP"
port = 5000
}
cpu = 0.5
memory = "1Gi"
}
}
secret {
name = "container-registry-password"
value = var.registry_credentials.registry_key
}
}
Deployment:
refer:
azurerm_container_app_job | Resources | hashicorp/azurerm | Terraform | Terraform Registry
azurerm_container_app_job | Resources | hashicorp/azurerm | Terraform | Terraform Registry answered by Venkat V