Skip to content

Commit

Permalink
PUB-2182 add terraform_format.yml (#400)
Browse files Browse the repository at this point in the history
* PUB-2182 add terraform_format.yml

* Automated Change

---------

Co-authored-by: NatashaAlker <[email protected]>
  • Loading branch information
NatashaAlker and NatashaAlker authored Jan 4, 2024
1 parent 543033d commit 4749d67
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 15 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/terraform_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Format terraform files

permissions:
contents: write

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
format:
runs-on: ubuntu-latest
name: Check terraform file are formatted correctly
steps:
- name: Checkout
uses: actions/checkout@v3

- name: terraform fmt
uses: dflook/terraform-fmt@v1

- name: commit format changes to branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automated Change
commit_user_name: Terraform format GitHub Actions Bot
2 changes: 1 addition & 1 deletion infrastructure/demo.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
env="demo"
env = "demo"
10 changes: 5 additions & 5 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ locals {
env_long_name = var.env == "sbox" ? "sandbox" : var.env == "stg" ? "staging" : var.env
env_subdomain = local.env_long_name == "prod" ? "" : "${local.env_long_name}."

base_url = "${var.product}-${var.component}.${local.env_subdomain}platform.hmcts.net"
prefix = "${var.product}-ss"
base_url = "${var.product}-${var.component}.${local.env_subdomain}platform.hmcts.net"
prefix = "${var.product}-ss"

apim_name = "sds-api-mgmt-${local.env}"
apim_rg = "ss-${local.env}-network-rg"
apim_name = "sds-api-mgmt-${local.env}"
apim_rg = "ss-${local.env}-network-rg"

deploy_apim = local.env == "stg" || local.env == "demo" || local.env == "test" || local.env == "sbox" || local.env == "prod" ? 1 : 0
deploy_apim = local.env == "stg" || local.env == "demo" || local.env == "test" || local.env == "sbox" || local.env == "prod" ? 1 : 0
}
2 changes: 1 addition & 1 deletion infrastructure/prod.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
env="prod"
env = "prod"
8 changes: 4 additions & 4 deletions infrastructure/providers.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.83.0"
}
azurerm = {
source = "hashicorp/azurerm"
version = "3.83.0"
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/stg.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
env="stg"
env = "stg"
2 changes: 1 addition & 1 deletion infrastructure/test.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
env="test"
env = "test"
2 changes: 1 addition & 1 deletion infrastructure/tf-apim-api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ locals {
apim_api_name = "${var.product}-${var.component}-api"
api_policy_raw = file("./resources/api-policy/api-policy.xml")
api_policy = replace(replace(local.api_policy_raw, "{TENANT_ID}", data.azurerm_client_config.current.tenant_id)
, "{ENV}", local.env)
, "{ENV}", local.env)
}

module "apim_api" {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/tf-apim-operations.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
basename(operation_policies_file) => {
operation_id = replace(basename(operation_policies_file), ".xml", "")
xml_content = replace(replace(file("${path.module}/${operation_policies_file}"), "{TENANT_ID}", data.azurerm_client_config.current.tenant_id)
, "{ENV}", local.env)
, "{ENV}", local.env)
}
}
}
Expand Down

0 comments on commit 4749d67

Please sign in to comment.