diff --git a/.github/workflows/terraform-plan.yml b/.github/workflows/terraform-plan.yml index 0817d5c..738e357 100644 --- a/.github/workflows/terraform-plan.yml +++ b/.github/workflows/terraform-plan.yml @@ -110,9 +110,9 @@ jobs: # issue-body: "Review the terraform plan, then approve." # exclude-workflow-initiator-as-approver: false - - name: Apply Terraform changes - id: apply - run: terraform apply -auto-approve + #- name: Apply Terraform changes + # id: apply + # run: terraform apply -auto-approve - name: Remove Runner to KV whitelist uses: azure/CLI@v1 diff --git a/terraform/locals.tf b/terraform/locals.tf index f311b45..c8678e5 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -10,12 +10,11 @@ locals { azure_location = var.azure_location resource_prefix = "${local.environment}${local.project_name}" azure_resource_group_name = var.resource_group_name - #registry_server = var.registry_server - #registry_username = var.registry_username - #registry_password = var.registry_password - #registry_custom_image_url = var.registry_custom_image_url - #resource_group_name = var.resource_group_name - + registry_server = var.registry_server + registry_username = var.registry_username + registry_password = var.registry_password + registry_custom_image_url = var.registry_custom_image_url + resource_group_name = module.main_hosting.azurerm_resource_group_default.name tags = { "Environment" = var.az_tag_environment, @@ -27,11 +26,11 @@ locals { ######################## ### Container App ### ######################## - /* + container_app_image_name = var.container_app_image_name container_port = var.az_container_port kestrel_endpoint = var.az_app_kestrel_endpoint - */ + ################## # Azure KeyVault # ################## @@ -47,5 +46,5 @@ locals { #################### # Managed Identity # #################### - # user_identity_name = var.serviceprinciple_identity + user_identity_name = var.serviceprinciple_identity } diff --git a/terraform/main-hosting.tf b/terraform/main-hosting.tf index 4eb00ec..8872f20 100644 --- a/terraform/main-hosting.tf +++ b/terraform/main-hosting.tf @@ -59,3 +59,49 @@ } + +module "main_hosting" { + source = "github.com/DFE-Digital/terraform-azurerm-container-apps-hosting?ref=v1.2.0" + + ########### + # General # + ########### + environment = local.environment + project_name = local.project_name + azure_location = local.azure_location + tags = local.tags + + + + ################# + # Container App # + ################# + enable_container_registry = true + use_external_container_registry_url = true + image_name = local.container_app_image_name + container_port = local.container_port + container_secret_environment_variables = { + "AZURE_CLIENT_ID" = azurerm_user_assigned_identity.user_assigned_identity.client_id, + "KeyVaultName" = local.kv_name + } + + container_environment_variables = { + "Kestrel__Endpoints__Http__Url" = local.kestrel_endpoint, + "ASPNETCORE_FORWARDEDHEADERS_ENABLED" = "true" + } + + container_app_identities = { + type = "UserAssigned", + identity_ids = [azurerm_user_assigned_identity.user_assigned_identity.id] + } + + + ############################# + # Github Container Registry # + ############################# + registry_server = local.registry_server + registry_username = local.registry_username + registry_password = local.registry_password + registry_custom_image_url = local.registry_custom_image_url + +} \ No newline at end of file diff --git a/terraform/user-assigned-identity.tf b/terraform/user-assigned-identity.tf index 7991eef..158e6af 100644 --- a/terraform/user-assigned-identity.tf +++ b/terraform/user-assigned-identity.tf @@ -1,7 +1,7 @@ - /*resource "azurerm_user_assigned_identity" "user_assigned_identity" { +resource "azurerm_user_assigned_identity" "user_assigned_identity" { name = local.user_identity_name location = local.azure_location resource_group_name = local.azure_resource_group_name } -*/ + diff --git a/terraform/variables.tf b/terraform/variables.tf index 1a36c39..f816393 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -90,7 +90,7 @@ variable "msi_id" { } -/* + ################ # Container App# ################ @@ -141,4 +141,3 @@ variable "serviceprinciple_identity"{ description = "Variable to define the service principle" type = string } -*/ \ No newline at end of file