Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/dev275 tf upgrades #571

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cc57d84
upgrading azurerm 4
m-juckes-pins Oct 22, 2024
d0fcb26
upgrading azurerm 4
m-juckes-pins Oct 22, 2024
d0dce1f
chore(infrastructure): upgrading azurerm to v4
m-juckes-pins Oct 22, 2024
fbdbb0a
chore(infrastructure): upgrading azurerm to v4
m-juckes-pins Oct 22, 2024
262c270
chore(infrastructure): upgrading azurerm to v4
m-juckes-pins Oct 22, 2024
a6b25cf
chore(infrastructure): upgrading azurerm to v4
m-juckes-pins Oct 22, 2024
e8a12ab
chore(infrastructure): testing with the azurerm tooling included in t…
m-juckes-pins Oct 22, 2024
ce8da35
chore(infrastructure): testing with the azurerm providers alias
m-juckes-pins Oct 22, 2024
df3647f
adding in tooling_config into web_app.tf and have removed the terrafo…
m-juckes-pins Oct 23, 2024
42de6c4
adding health_check_eviction_time_in_min into the web app>site_config
m-juckes-pins Oct 23, 2024
0bc2b4a
changing sensitive to base64
m-juckes-pins Oct 23, 2024
88bbe15
adding output in module
m-juckes-pins Oct 23, 2024
463c81f
changing docker settings on the module
m-juckes-pins Oct 23, 2024
15642fe
changing monitoring location to global
m-juckes-pins Oct 24, 2024
0787023
changing application_stack and docker settings
m-juckes-pins Oct 24, 2024
ee2e45d
upgrading to azreurm to version 4 to match modules
m-juckes-pins Nov 7, 2024
8d3a2b7
feat(appeals): upgrading to azreurm to version 4 to match modules
m-juckes-pins Nov 7, 2024
c7de746
upgrading azurerm 4
m-juckes-pins Oct 22, 2024
a33a50d
feat(appeals): upgrading to azreurm to version 4 to match modules
m-juckes-pins Nov 7, 2024
59a783b
feat(appeals): upgrading to azreurm to version 4 to match modules
m-juckes-pins Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
default_install_hook_types: [commit-msg, pre-commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
stages: [pre-commit]
- id: trailing-whitespace
stages: [pre-commit]
- id: check-json
stages: [pre-commit]
- id: check-yaml
stages: [pre-commit]
args:
- --unsafe
- id: check-symlinks
stages: [pre-commit]
- id: check-added-large-files
stages: [pre-commit]
args:
- --maxkb=15000
- id: detect-private-key
stages: [pre-commit]

- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.96.1
hooks:
- id: terraform_fmt
stages: [pre-commit]
- id: terraform_docs
stages: [pre-commit]
args:
- --args=--config=.config/terraform-docs.yml
- --hook-config=--use-standard-markers=true
exclude: "^modules|^example|^tools"
- id: terraform_validate
stages: [pre-commit]
exclude: ^examples
args:
- --tf-init-args=-upgrade
- --hook-config=--retry-once-with-cleanup=true
- id: terraform_tflint
stages: [pre-commit]
exclude: ^examples
args:
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
- id: terraform_trivy
stages: [pre-commit]
- id: terraform_checkov

# - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
# rev: v9.18.0
# hooks:
# - id: commitlint
# stages: [commit-msg]
# additional_dependencies: ["@commitlint/config-conventional"]
45 changes: 45 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
config {
disabled_by_default = false
}

plugin "azurerm" {
enabled = true
version = "0.26.0"
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}

rule "terraform_comment_syntax" {
enabled = true
}

rule "terraform_documented_outputs" {
enabled = true
}

rule "terraform_documented_variables" {
enabled = true
}

rule "terraform_required_providers" {
enabled = false
}

rule "terraform_required_version" {
enabled = false
}

rule "terraform_naming_convention" {
enabled = true
}

rule "terraform_typed_variables" {
enabled = true
}

rule "terraform_unused_declarations" {
enabled = true
}

rule "terraform_unused_required_providers" {
enabled = true
}
2 changes: 1 addition & 1 deletion infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Differences between environments are managed with simple tfvars files, found in

Variables with common values across environments are set in the `terraform.tfvars` file, which Terraform looks for automatically.

https://developer.hashicorp.com/terraform/language/values/variables#variable-definitions-tfvars-files
<https://developer.hashicorp.com/terraform/language/values/variables#variable-definitions-tfvars-files>
12 changes: 7 additions & 5 deletions infrastructure/app-api.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module "app_api" {
#checkov:skip=CKV_TF_1: Use of commit hash are not required for our Terraform modules
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-app-service?ref=1.24"
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-app-service?ref=7e4e94e"

resource_group_name = azurerm_resource_group.primary.name
location = module.primary_region.location

tooling_config = var.tooling_config

# naming
app_name = "api"
resource_suffix = var.environment
Expand Down Expand Up @@ -96,10 +98,10 @@ module "app_api" {

}

providers = {
azurerm = azurerm
azurerm.tooling = azurerm.tooling
Copy link
Contributor Author

@m-juckes-pins m-juckes-pins Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This couldn't pass the validation with it in

│ Error: Cannot override provider configuration 
│ 
│   on app-api.tf line 101, in module "app_api":
│  101:     azurerm.tooling = azurerm.tooling   
│ 
│ The configuration of module.app_api has its own local configuration for azurerm.tooling, and so it cannot accept an overridden configuration provided by the root module.

}
# providers = {
# azurerm = azurerm
# azurerm.tooling = azurerm.tooling
# }
}

## RBAC for secrets
Expand Down
12 changes: 7 additions & 5 deletions infrastructure/app-web.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module "app_web" {
#checkov:skip=CKV_TF_1: Use of commit hash are not required for our Terraform modules
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-app-service?ref=1.24"
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-app-service?ref=7e4e94e"

resource_group_name = azurerm_resource_group.primary.name
location = module.primary_region.location

tooling_config = var.tooling_config

# naming
app_name = "web"
resource_suffix = var.environment
Expand Down Expand Up @@ -79,10 +81,10 @@ module "app_web" {
FEATURE_FLAG_S78_WRITTEN = var.apps_config.featureFlags.featureFlagS78Written
}

providers = {
azurerm = azurerm
azurerm.tooling = azurerm.tooling
}
# providers = {
# azurerm = azurerm
# azurerm.tooling = azurerm.tooling
# }
}

## RBAC for secrets
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/data-front-office.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ data "azurerm_storage_container" "front_office_documents" {

name = "uploads"
storage_account_name = replace("pinsstdocs${var.environment}ukw001", "-", "")
}
}
2 changes: 1 addition & 1 deletion infrastructure/database-monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "azurerm_storage_account" "sql_server" {
account_tier = "Standard"
account_replication_type = "GRS"
min_tls_version = "TLS1_2"
enable_https_traffic_only = true
https_traffic_only_enabled = true
allow_nested_items_to_be_public = false
cross_tenant_replication_enabled = false

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/document-storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "azurerm_storage_account" "documents" {
account_replication_type = var.documents_config.account_replication_type
allow_nested_items_to_be_public = true
cross_tenant_replication_enabled = false
enable_https_traffic_only = true
https_traffic_only_enabled = true
min_tls_version = "TLS1_2"

tags = local.tags
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/function-casedata-import.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "function_casedata_import" {
#checkov:skip=CKV_TF_1: Use of commit hash are not required for our Terraform modules
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=1.24"
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=7e4e94e"

resource_group_name = azurerm_resource_group.primary.name
location = module.primary_region.location
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/function-doc-processing.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "function_doc_processing" {
#checkov:skip=CKV_TF_1: Use of commit hash are not required for our Terraform modules
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=1.24"
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=7e4e94e"

resource_group_name = azurerm_resource_group.primary.name
location = module.primary_region.location
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/function-scheduled-jobs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "function_scheduled_jobs" {
#checkov:skip=CKV_TF_1: Use of commit hash are not required for our Terraform modules
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=1.24"
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=7e4e94e"

resource_group_name = azurerm_resource_group.primary.name
location = module.primary_region.location
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/function-user-import.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "function_user_import" {
#checkov:skip=CKV_TF_1: Use of commit hash are not required for our Terraform modules
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=1.24"
source = "github.com/Planning-Inspectorate/infrastructure-modules.git//modules/node-function-app?ref=7e4e94e"

resource_group_name = azurerm_resource_group.primary.name
location = module.primary_region.location
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/function.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resource "azurerm_storage_account" "functions" {
account_replication_type = "GRS"
allow_nested_items_to_be_public = false
cross_tenant_replication_enabled = false
enable_https_traffic_only = true
https_traffic_only_enabled = true
min_tls_version = "TLS1_2"

tags = local.tags
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module "primary_region" {
source = "claranet/regions/azurerm"
version = "7.1.1"
version = "7.2.1"

azure_region = local.primary_location
}

module "secondary_region" {
source = "claranet/regions/azurerm"
version = "7.1.1"
version = "7.2.1"

azure_region = local.secondary_location
}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ resource "azurerm_key_vault_secret" "app_insights_connection_string" {
content_type = "connection-string"

tags = local.tags
}
}
18 changes: 10 additions & 8 deletions infrastructure/networking-secondary.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ resource "azurerm_virtual_network" "secondary" {
}

resource "azurerm_subnet" "secondary_apps" {
name = "${local.org}-snet-${local.service_name}-apps-secondary-${var.environment}"
resource_group_name = azurerm_resource_group.secondary.name
virtual_network_name = azurerm_virtual_network.secondary.name
address_prefixes = [var.vnet_config.secondary_apps_subnet_address_space]
name = "${local.org}-snet-${local.service_name}-apps-secondary-${var.environment}"
resource_group_name = azurerm_resource_group.secondary.name
virtual_network_name = azurerm_virtual_network.secondary.name
address_prefixes = [var.vnet_config.secondary_apps_subnet_address_space]
private_endpoint_network_policies = "Enabled"

# for app services
delegation {
Expand All @@ -27,10 +28,11 @@ resource "azurerm_subnet" "secondary_apps" {
}

resource "azurerm_subnet" "secondary" {
name = "${local.org}-snet-${local.secondary_resource_suffix}"
resource_group_name = azurerm_resource_group.secondary.name
virtual_network_name = azurerm_virtual_network.secondary.name
address_prefixes = [var.vnet_config.secondary_subnet_address_space]
name = "${local.org}-snet-${local.secondary_resource_suffix}"
resource_group_name = azurerm_resource_group.secondary.name
virtual_network_name = azurerm_virtual_network.secondary.name
address_prefixes = [var.vnet_config.secondary_subnet_address_space]
private_endpoint_network_policies = "Enabled"
}

resource "azurerm_virtual_network_peering" "secondary_bo_to_tooling" {
Expand Down
18 changes: 10 additions & 8 deletions infrastructure/networking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ resource "azurerm_virtual_network" "main" {
}

resource "azurerm_subnet" "apps" {
name = "${local.org}-snet-${local.service_name}-apps-${var.environment}"
resource_group_name = azurerm_resource_group.primary.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.vnet_config.apps_subnet_address_space]
name = "${local.org}-snet-${local.service_name}-apps-${var.environment}"
resource_group_name = azurerm_resource_group.primary.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.vnet_config.apps_subnet_address_space]
private_endpoint_network_policies = "Enabled"

# for app services
delegation {
Expand All @@ -27,10 +28,11 @@ resource "azurerm_subnet" "apps" {
}

resource "azurerm_subnet" "main" {
name = "${local.org}-snet-${local.resource_suffix}"
resource_group_name = azurerm_resource_group.primary.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.vnet_config.main_subnet_address_space]
name = "${local.org}-snet-${local.resource_suffix}"
resource_group_name = azurerm_resource_group.primary.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.vnet_config.main_subnet_address_space]
private_endpoint_network_policies = "Enabled"
}

## peer to tooling VNET for DevOps agents
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/pipelines/terraform-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
trigger:
trigger:
branches:
include:
- main
Expand Down
8 changes: 4 additions & 4 deletions infrastructure/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.99.0"
version = "=4.5.0"
}
}
required_version = ">= 1.1.6, < 1.10.0"
Expand All @@ -27,9 +27,9 @@ provider "azurerm" {
}

provider "azurerm" {
alias = "horizon"
subscription_id = var.horizon_infra_config.subscription_id
skip_provider_registration = true
alias = "horizon"
subscription_id = var.horizon_infra_config.subscription_id
resource_provider_registrations = "none"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


features {}
}
1 change: 0 additions & 1 deletion infrastructure/service-bus.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ resource "azurerm_servicebus_namespace" "main" {

sku = var.service_bus_config.sku
capacity = var.service_bus_config.capacity
zone_redundant = var.service_bus_config.sku == "Premium"
premium_messaging_partitions = var.service_bus_config.sku == "Premium" ? 1 : 0

minimum_tls_version = "1.2"
Expand Down
Loading