### Deploy HTTP Route Configurations Module Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/http_route_configs/_header.md Example of how to deploy the http_route_configs submodule in Terraform. Ensure you replace '' with the correct module version. ```hcl module "http_route_configs" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/http_route_configs" version = "" name = "my-routes" parent_id = "/subscriptions/.../managedEnvironments/my-env" custom_domains = [] rules = [] } ``` -------------------------------- ### Configure Workload Profiles for Managed Environment Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Example of how to define workload profiles for a Managed Environment. This includes specifying the profile name, type, and instance counts. ```hcl workload_profiles = [{ name = "Dedicated" workload_profile_type = "D4" maximum_count = 3 minimum_count = 1 }] ``` -------------------------------- ### Terraform Module Source from GitHub Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/AGENTS.md This example demonstrates referencing an AVM module hosted on GitHub. Replace `{type}`, `{service}`, and `{resource}` with the appropriate values for the module you are using. ```terraform source = "https://github.com/Azure/terraform-azurerm-avm-{type}-{service}-{resource}" ``` -------------------------------- ### Deploy .NET Aspire Component Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/dot_net_components/_header.md Example of deploying a .NET Aspire-compatible component, such as the Aspire Dashboard, using the dot_net_components module. Ensure the 'version' is updated to the latest release. ```hcl module "dot_net_components" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/dot_net_components" version = "" name = "aspire-dashboard" parent_id = "/subscriptions/.../managedEnvironments/my-env" component_type = "AspireDashboard" configurations = [] service_binds = [] } ``` -------------------------------- ### Terraform Versions API for Module Versions Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/AGENTS.md This example shows the URL structure for querying the Terraform Registry API to retrieve versions for a specific AVM module. Replace `{module}` with the module name. ```terraform source = "https://registry.terraform.io/v1/modules/Azure/{module}/[azurerm|azure]/versions" ``` -------------------------------- ### Terraform Module Source from Registry Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/AGENTS.md This example shows how to reference an AVM module directly from the Terraform Registry. Remember to replace `{module}` with the specific module name. ```terraform source = "https://registry.terraform.io/modules/Azure/{module}/azurerm/latest" ``` -------------------------------- ### Terraform Configuration for Storage Example Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/storage_share/README.md This snippet sets up the necessary Terraform providers, resources like resource group, Log Analytics workspace, and storage account, and then deploys the Managed Environment module with storage configuration. ```hcl terraform { required_version = ">= 1.9, < 2.0" required_providers { # ignore this because we want to force the use of AzAPI v1 within the module without having it used in this example. # tflint-ignore: terraform_unused_required_providers azapi = { source = "Azure/azapi" version = "~> 2.0" } azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { resource_provider_registrations = "none" features { resource_group { prevent_deletion_if_contains_resources = false } } } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" name = module.naming.resource_group.name_unique } resource "azurerm_log_analytics_workspace" "this" { location = azurerm_resource_group.this.location name = module.naming.log_analytics_workspace.name_unique resource_group_name = azurerm_resource_group.this.name } resource "azurerm_storage_account" "this" { account_replication_type = "ZRS" account_tier = "Standard" location = azurerm_resource_group.this.location name = module.naming.storage_account.name_unique resource_group_name = azurerm_resource_group.this.name } resource "azurerm_storage_share" "this" { name = "sharename" quota = 5 storage_account_id = azurerm_storage_account.this.id } module "managedenvironment" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.container_app_environment.name_unique resource_group_name = azurerm_resource_group.this.name log_analytics_workspace = { resource_id = azurerm_log_analytics_workspace.this.id } storages = { "mycontainerappstorage" = { azure_file = { access_mode = "ReadOnly" account_name = azurerm_storage_account.this.name share_name = azurerm_storage_share.this.name } account_key = azurerm_storage_account.this.primary_access_key account_key_version = 1 location = azurerm_resource_group.this.location name = "mycontainerappstorage" } } # zone redundancy must be disabled unless we supply a subnet for vnet integration. zone_redundant = false } moved { from = module.managedenvironment.azapi_resource.storages["mycontainerappstorage"] to = module.managedenvironment.module.storages["mycontainerappstorage"].azapi_resource.this } ``` -------------------------------- ### Deploy a Java Managed Component (Eureka Server) Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/java_components/_header.md Example of deploying a Spring Cloud Eureka server as a Java managed component. Ensure the 'version' is updated to the latest AVM module version. ```hcl module "java_components" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/java_components" version = "" name = "eureka" parent_id = "/subscriptions/.../managedEnvironments/my-env" component_type = "SpringCloudEureka" configurations = [] ingress = {} scale = {} service_binds = [] } ``` -------------------------------- ### Terraform Configuration for Dapr Component Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/dapr_components/_header.md Example of how to configure a Dapr state store component using the dapr_components module. Ensure the 'version' is updated to the latest release. ```hcl module "dapr_components" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/dapr_components" version = "" name = "statestore" parent_id = "/subscriptions/.../managedEnvironments/my-env" component_type = "state.azure.blobstorage" metadata = [ { name = "accountName", value = "mystorageaccount" }, { name = "containerName", value = "state" }, ] secrets = [] } ``` -------------------------------- ### Terraform Configuration for Certificate Example Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/certificate/README.md This snippet sets up the necessary Terraform providers, naming conventions, resource group, Log Analytics workspace, and an Azure Key Vault for storing certificates. It also configures a user-assigned managed identity and grants it permissions to access secrets in the Key Vault. ```hcl terraform { required_version = ">= 1.9, < 2.0" required_providers { # ignore this because we want to force the use of AzAPI v1 within the module without having it used in this example. # tflint-ignore: terraform_unused_required_providers azapi = { source = "Azure/azapi" version = "~> 2.0" } azurerm = { source = "hashicorp/azurerm" version = "~> 4.0" } } } provider "azurerm" { resource_provider_registrations = "none" features { resource_group { prevent_deletion_if_contains_resources = false } } } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.0" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" name = module.naming.resource_group.name_unique } resource "azurerm_log_analytics_workspace" "this" { location = azurerm_resource_group.this.location name = module.naming.log_analytics_workspace.name_unique resource_group_name = azurerm_resource_group.this.name } # Example: Create a Key Vault for certificate storage resource "azurerm_key_vault" "this" { location = azurerm_resource_group.this.location name = module.naming.key_vault.name_unique resource_group_name = azurerm_resource_group.this.name sku_name = "standard" tenant_id = data.azurerm_client_config.current.tenant_id enable_rbac_authorization = true purge_protection_enabled = false soft_delete_retention_days = 7 } data "azurerm_client_config" "current" {} # Example managed identity for Key Vault access resource "azurerm_user_assigned_identity" "this" { location = azurerm_resource_group.this.location name = "${module.naming.user_assigned_identity.name_unique}-env" resource_group_name = azurerm_resource_group.this.name } # Grant the managed identity permission to read certificates from Key Vault resource "azurerm_role_assignment" "kv_secrets_user" { principal_id = azurerm_user_assigned_identity.this.principal_id scope = azurerm_key_vault.this.id role_definition_name = "Key Vault Secrets User" } module "managedenvironment" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.container_app_environment.name_unique resource_group_name = azurerm_resource_group.this.name log_analytics_workspace = { resource_id = azurerm_log_analytics_workspace.this.id } # Configure managed identity for Key Vault access managed_identities = { user_assigned_resource_ids = [azurerm_user_assigned_identity.this.id] } # zone redundancy must be disabled unless we supply a subnet for vnet integration. zone_redundant = false } ``` -------------------------------- ### Deploy Managed Certificates Module Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/managed_certificates/_header.md Example of deploying the managed_certificates module to provision an Azure-managed TLS certificate for a custom domain within a Container Apps Managed Environment. Ensure you replace '' with the correct module version. ```hcl module "managed_certificates" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/managed_certificates" version = "" name = "my-managed-cert" parent_id = "/subscriptions/.../managedEnvironments/my-env" location = "australiaeast" subject_name = "myapp.example.com" } ``` -------------------------------- ### Pinning AVM Module Version in Terraform Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/AGENTS.md When using AVM modules, it's crucial to pin to a specific version for predictable deployments. This example shows the standard way to specify the version. ```terraform version = "1.2.3" ``` -------------------------------- ### Configure Dapr Subscription in Azure Container Apps Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/dapr_subscriptions/_header.md Example of how to configure a Dapr subscription for a Container Apps Managed Environment using the AVM module. This sets up a basic subscription to a topic with a default route. ```hcl module "dapr_subscriptions" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/dapr_subscriptions" version = "" name = "my-subscription" parent_id = "/subscriptions/.../managedEnvironments/my-env" pubsub_name = "my-pubsub" topic = "orders" bulk_subscribe = { enabled = false } routes = { default = "/orders" } } ``` -------------------------------- ### Configure Maintenance Window Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/maintenance_configurations/_header.md Defines a weekly maintenance window for a Container Apps Managed Environment. Specify the name, parent resource ID, and the schedule details including day of week, duration, and start hour. ```hcl module "maintenance_configurations" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/maintenance_configurations" version = "" name = "weekly-window" parent_id = "/subscriptions/.../managedEnvironments/my-env" scheduled_entries = [{ day_of_week = "Monday" duration_in_hours = 8 start_hour_utc = 2 }] } ``` -------------------------------- ### Direct Certificate Upload to Managed Environment Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/certificate/_footer.md Use this method to upload a certificate directly by providing its base64-encoded value and password. Ensure the certificate file is correctly encoded. ```hcl certificates = { "example-cert" = { certificate_value = filebase64("./mycert.pfx") certificate_password = "MyPassword123!" } } ``` -------------------------------- ### .NET Components Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines .NET components to be created on the Container Apps Managed Environment. Supports specifying component type, configurations, and service bindings. ```hcl map(object({ component_type = optional(any) configurations = optional(list(object({ property_name = optional(string) value = optional(string) }))) name = string service_binds = optional(list(object({ name = optional(string) service_id = optional(string) }))) })) ``` -------------------------------- ### Storage Definition Migration: Flat to Nested Structure Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/UPGRADE.md Illustrates the change in how storage definitions are structured, moving Azure Files settings and account keys into nested blocks with version trackers. ```hcl storages = { "my-storage" = { access_key = "..." access_mode = "ReadWrite" account_name = "mystorageaccount" share_name = "myshare" } } ``` ```hcl storages = { "my-storage" = { name = "my-storage" azure_file = { access_mode = "ReadWrite" account_name = "mystorageaccount" share_name = "myshare" } account_key = "..." account_key_version = 1 } } ``` -------------------------------- ### Java Components Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines a map of Java components to be created on the Container Apps Managed Environment. Each component supports various configurations including ingress, scale, and service binds. ```hcl map(object({ component_type = string configurations = optional(list(object({ property_name = optional(string) value = optional(string) }))) ingress = optional(object({})) name = string scale = optional(object({ max_replicas = optional(number) min_replicas = optional(number) })) service_binds = optional(list(object({ name = optional(string) service_id = optional(string) }))) })) ``` -------------------------------- ### App Logs Configuration Object Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for application logs configuration, specifying the destination and optional Log Analytics details. ```hcl object({ destination = optional(string) log_analytics_configuration = optional(object({ customer_id = optional(string) dynamic_json_columns = optional(bool) })) }) ``` -------------------------------- ### HTTP Validation File Path Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/managed_certificate/_footer.md Host a validation file at this specific HTTP path on your domain to prove ownership. This method requires a web server to be accessible. ```http http://yourdomain.com/.well-known/acme-challenge/ ``` -------------------------------- ### HTTP Validation File Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/managed_certificate/README.md Host a specific validation file at a designated URL to prove domain ownership. This method involves placing a token file in a specific directory on your web server. ```http http://yourdomain.com/.well-known/acme-challenge/ ``` -------------------------------- ### Direct Certificate Upload Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/certificate/README.md Use `certificate_value` (base64-encoded) and `certificate_password` for direct upload of a certificate. ```hcl certificates = { "example-cert" = { certificate_value = filebase64("./mycert.pfx") certificate_password = "MyPassword123!" } } ``` -------------------------------- ### Ingress Configuration Object Structure Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Specifies the structure for ingress configuration in a Managed Environment, including header limits, idle timeouts, and termination grace periods. ```hcl object({ header_count_limit = optional(number) request_idle_timeout = optional(number) termination_grace_period_seconds = optional(number) workload_profile_name = optional(string) }) ``` -------------------------------- ### TXT Validation Record Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/examples/managed_certificate/_footer.md Create a TXT record with the provided validation token to verify domain ownership. This method is an alternative to CNAME validation. ```dns _acme-challenge.yourdomain.com TXT ``` -------------------------------- ### HTTP Route Configuration Structure Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for HTTP route configurations within a Container Apps Managed Environment. This includes custom domains and routing rules. ```hcl map(object({ custom_domains = optional(list(object({ binding_type = optional(any) certificate_id = optional(string) name = string }))) name = string rules = optional(list(object({ description = optional(string) routes = optional(list(object({ action = optional(object({ prefix_rewrite = optional(string) })) match = optional(object({ case_sensitive = optional(bool) path = optional(string) path_separated_prefix = optional(string) prefix = optional(string) })) }))) targets = optional(list(object({ container_app = string label = optional(string) revision = optional(string) }))) }))) })) ``` -------------------------------- ### Custom Domain Configuration Object Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the custom domain configuration for the environment, including certificate details and DNS suffix. Supports certificates stored in Azure Key Vault or provided directly. ```hcl object({ certificate_key_vault_properties = optional(object({ identity = optional(string) key_vault_url = optional(string) })) certificate_value = optional(any) dns_suffix = optional(string) }) ``` -------------------------------- ### Certificate Object for Custom Domain Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for a map of certificates to be created on the Container Apps Managed Environment, supporting Key Vault integration. ```hcl map(object({ certificate_key_vault_properties = optional(object({ identity = optional(string) key_vault_url = optional(string) })) location = string name = string password = optional(string) password_version = optional(number) tags = optional(map(string)) value = optional(any) value_version = optional(number) })) ``` -------------------------------- ### Configure Certificates Submodule Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/certificates/_header.md Use this snippet to define and configure the certificates submodule for a Container Apps Managed Environment. It specifies the source, version, and essential properties like name, parent ID, location, and Key Vault integration details. ```hcl module "certificates" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/certificates" version = "" name = "my-cert" parent_id = "/subscriptions/.../managedEnvironments/my-env" location = "australiaeast" certificate_key_vault_properties = { key_vault_url = "https://my-kv.vault.azure.net/certificates/my-cert" identity = "/subscriptions/.../userAssignedIdentities/my-identity" } } ``` -------------------------------- ### Certificate Schema Restructuring: AzAPI Alignment Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/UPGRADE.md Demonstrates the new certificate schema, which is aligned with the AzAPI body shape, including explicit metadata and version trackers for sensitive data. ```hcl certificates = { "my-cert" = { certificate_password = "..." certificate_value = "..." } } ``` ```hcl certificates = { "my-cert" = { name = "my-cert" location = "eastus" password = "..." password_version = 1 value = "..." value_version = 1 certificate_key_vault_properties = { identity = "..." key_vault_url = "..." } } } ``` -------------------------------- ### Workload Profile Configuration (Deprecated) Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines workload profiles for the Managed Environment. This input is deprecated and will be removed in a future release; use `workload_profiles` instead. ```hcl set(object({ maximum_count = optional(number) minimum_count = optional(number) name = string workload_profile_type = string })) ``` -------------------------------- ### Open Telemetry Configuration Schema Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for OpenTelemetry configuration on a Container Apps Managed Environment. Use this for advanced monitoring and diagnostics. ```hcl object({ destinations_configuration = optional(object({ data_dog_configuration = optional(object({ key = optional(string) site = optional(string) })) otlp_configurations = optional(list(object({ endpoint = optional(string) headers = optional(list(object({ key = optional(string) value = optional(string) }))) insecure = optional(bool) name = optional(string) }))) })) logs_configuration = optional(object({ destinations = optional(list(string)) })) metrics_configuration = optional(object({ destinations = optional(list(string)) include_keda = optional(bool) })) traces_configuration = optional(object({ destinations = optional(list(string)) include_dapr = optional(bool) })) }) ``` -------------------------------- ### Configure Azure Files Storage Mount Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/modules/storages/_header.md Use this snippet to define an Azure Files storage mount for a Container Apps Managed Environment. Ensure you have the correct version of the module and provide the necessary parent ID, storage account details, and share name. ```hcl module "storages" { source = "Azure/avm-res-app-managedenvironment/azurerm//modules/storages" version = "" name = "my-storage" parent_id = "/subscriptions/.../managedEnvironments/my-env" azure_file = { access_mode = "ReadWrite" account_name = "mystorageaccount" share_name = "myshare" } nfs_azure_file = {} } ``` -------------------------------- ### Using Pessimistic Constraints for Terraform Providers Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/AGENTS.md When defining provider versions for AVM modules, use pessimistic version constraints (e.g., `~> 1.0`). This allows for patch updates while preventing breaking changes from minor or major version updates. ```terraform version = "~> 1.0" ``` -------------------------------- ### Timeouts Configuration for Container Apps Managed Environment Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Configures operation timeouts for create, delete, read, and update actions on the Container App Environment. Defaults are provided for each operation. ```hcl object({ create = optional(string) delete = optional(string) read = optional(string) update = optional(string) }) ``` -------------------------------- ### App Insights Configuration Object Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for Application Insights configuration, including an optional connection string. ```hcl object({ connection_string = optional(string) }) ``` -------------------------------- ### Resource Lock Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Specifies the Resource Lock configuration for a resource. Supports defining the lock kind and an optional name. Changing the lock kind forces resource recreation. ```hcl object({ kind = string name = optional(string, null) }) ``` -------------------------------- ### Managed Certificates Schema Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for managed certificates on a Container Apps Managed Environment. Use this to configure custom certificates. ```hcl map(object({ domain_control_validation = optional(any) location = string name = string subject_name = optional(string) tags = optional(map(string)) })) ``` -------------------------------- ### Maintenance Configurations Schema Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the structure for maintenance configurations on a Container Apps Managed Environment. Use this to specify scheduled maintenance. ```hcl map(object({ name = string scheduled_entries = list(object({ duration_hours = number start_hour_utc = number week_day = string })) })) ``` -------------------------------- ### Storage Definition for Container Apps Managed Environment Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines storage resources for the Container Apps Managed Environment. Supports Azure file shares and NFS Azure file shares, with options for Key Vault integration for account keys. ```hcl map(object({ account_key = optional(string) account_key_version = optional(number) azure_file = optional(object({ access_mode = optional(any) account_key = optional(string) account_key_vault_properties = optional(object({ identity = optional(string) key_vault_url = optional(string) })) account_name = optional(string) share_name = optional(string) })) name = string nfs_azure_file = optional(object({ access_mode = optional(any) server = optional(string) share_name = optional(string) })) })) ``` -------------------------------- ### Log Analytics Workspace Resource ID Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Defines the configuration for linking a Log Analytics Workspace to a Container Apps Managed Environment using its resource ID. This is the recommended method to avoid passing shared keys directly. ```hcl object({ resource_id = string }) ``` -------------------------------- ### Disk Encryption Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-app-managedenvironment/blob/main/README.md Configures disk encryption for a Managed Environment using Azure Key Vault. This is a preview feature, so check product documentation for support and clarification. ```hcl object({ key_vault_configuration = optional(object({ auth = optional(object({ identity = optional(string) })) key_url = optional(string) })) }) ```