Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain-Stanger committed Jun 18, 2024
2 parents 6845b17 + 0b54167 commit c142aee
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 119 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/terraform-pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@ env:
TF_VAR_az_app_kestrel_endpoint: ${{ vars.KESTRELENDPOINT }}
TF_VAR_az_tag_environment: ${{ vars.AZ_TAG_ENVIRONMENT }}
TF_VAR_az_tag_product: ${{ vars.AZ_TAG_PRODUCT }}
TF_VAR_registry_server: "ghcr.io"
TF_VAR_az_sql_admin_userid_postfix: ${{secrets.AZ_SQL_ADMIN_USERID_POSTFIX}}
TF_VAR_az_sql_azuread_admin_username: ${{ secrets.AZ_SERVICE_PRINCIPAL }}
TF_VAR_az_sql_admin_password: ${{secrets.AZ_SQL_ADMIN_PASSWORD}}
TF_VAR_az_sql_azuread_admin_objectid: ${{ secrets.AZ_CLIENT_ID }}
TF_VAR_registry_server: "ghcr.io/dfe-digital"
TF_VAR_image_tag: "latest"
TF_VAR_registry_username: ${{ github.repository_owner }}
TF_VAR_registry_custom_image_url: "ghcr.io/dfe-digital/sts-content-and-support:latest"
TF_VAR_registry_password: ${{ secrets.GITHUB_TOKEN }}

TF_WORKING_DIRECTORY: terraform/container-app

jobs:
validate-terraform:
name: Validate Terraform
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{env.TF_WORKING_DIRECTORY}}
Expand Down Expand Up @@ -140,7 +144,7 @@ jobs:
terraform-lint:
name: Terraform Lint
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{ env.TF_WORKING_DIRECTORY }}
Expand All @@ -158,7 +162,7 @@ jobs:

tfsec-pr-commenter:
name: tfsec Check
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Clone repo
uses: actions/checkout@v4
Expand Down
106 changes: 0 additions & 106 deletions terraform/container-app/.terraform.lock.hcl

This file was deleted.

8 changes: 6 additions & 2 deletions terraform/container-app/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ locals {
# Container App #
#################
container_app_image_name = "content-support-app"
kestrel_endpoint = var.az_app_kestrel_endpoint
container_port = var.az_container_port
kestrel_endpoint = var.az_app_kestrel_endpoint
container_port = var.az_container_port
image_tag = var.image_tag
container_app_min_replicas = var.container_app_min_replicas
container_app_max_replicas = var.container_app_max_replicas
container_app_http_concurrency = var.container_app_http_concurrency

####################
# Managed Identity #
Expand Down
12 changes: 8 additions & 4 deletions terraform/container-app/main-hosting.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "main_hosting" {
source = "github.com/DFE-Digital/terraform-azurerm-container-apps-hosting?ref=v1.6.2"
source = "github.com/DFE-Digital/terraform-azurerm-container-apps-hosting?ref=v1.6.4"

###########
# General #
Expand All @@ -12,9 +12,9 @@ module "main_hosting" {
#################
# Container App #
#################
enable_container_registry = true
image_name = local.container_app_image_name
container_port = local.container_port
enable_container_registry = 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
Expand All @@ -30,6 +30,10 @@ module "main_hosting" {
identity_ids = [azurerm_user_assigned_identity.user_assigned_identity.id]
}

container_max_replicas = local.container_app_max_replicas
container_min_replicas = local.container_app_min_replicas
container_scale_http_concurrency = local.container_app_http_concurrency


##############
# Networking #
Expand Down
4 changes: 2 additions & 2 deletions terraform/container-app/scripts/state-update-terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ RESOURCE_GROUP="$3"
STATE_CONTAINER="$4"
STATE_FILE="$5"
STATE_ACCOUNT="$6"
RESOURCE_GROUP_PREFIX="${RESOURCE_GROUP%%-conentsupport}"
RESOURCE_GROUP_PREFIX="${RESOURCE_GROUP%%-cs}"


terraform import -var-file="$VAR_FILE" module.main_hosting.azurerm_container_app_environment.container_app_env "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.App/managedEnvironments/${RESOURCE_GROUP}containerapp"

terraform state rm module.main_hosting.azapi_resource.container_app_env

terraform import -var-file="$VAR_FILE" 'module.main_hosting.azurerm_container_app.container_apps["main"]' "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.App/containerApps/${RESOURCE_GROUP}-plan-tech-app"
terraform import -var-file="$VAR_FILE" 'module.main_hosting.azurerm_container_app.container_apps["main"]' "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.App/containerApps/${RESOURCE_GROUP}-cs-app"

terraform state rm module.main_hosting.azapi_resource.default

Expand Down
22 changes: 22 additions & 0 deletions terraform/container-app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ variable "az_container_port" {
default = 8080
}

variable "image_tag" {
description = "Image tag"
type = string
}

variable "container_app_min_replicas" {
description = "Minimum replicas for the container app"
type = number
default = 1
}

variable "container_app_max_replicas" {
description = "Maximum replicas for the container app"
type = number
default = 2
}

variable "container_app_http_concurrency" {
description = "Scale up at this number of HTTP requests"
type = number
default = 10
}

##################
# CDN/Front Door #
Expand Down

0 comments on commit c142aee

Please sign in to comment.