forked from SAFEHR-data/FlowEHR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterragrunt.hcl
144 lines (130 loc) · 3.7 KB
/
terragrunt.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright (c) University College London Hospitals NHS Foundation Trust
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
terraform {
extra_arguments "auto_approve" {
commands = ["apply"]
arguments = ["-auto-approve"]
}
}
locals {
terraform_version = "1.3.7"
azure_provider = <<EOF
provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
key_vault {
# Don't purge on destroy (this would fail due to purge protection being enabled on keyvault)
purge_soft_delete_on_destroy = false
purge_soft_deleted_secrets_on_destroy = false
purge_soft_deleted_certificates_on_destroy = false
purge_soft_deleted_keys_on_destroy = false
# When recreating an environment, recover any previously soft deleted secrets - set to true by default
recover_soft_deleted_key_vaults = true
recover_soft_deleted_secrets = true
recover_soft_deleted_certificates = true
recover_soft_deleted_keys = true
}
}
}
EOF
required_provider_azure = <<EOF
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.32"
}
EOF
required_provider_azuread = <<EOF
azuread = {
source = "hashicorp/azuread"
version = "2.35.0"
}
EOF
required_provider_random = <<EOF
random = {
source = "hashicorp/random"
version = "3.4.3"
}
EOF
required_provider_databricks = <<EOF
databricks = {
source = "databricks/databricks"
version = "1.9.1"
}
EOF
required_provider_external = <<EOF
external = {
source = "hashicorp/external"
version = "2.2.3"
}
EOF
required_provider_null = <<EOF
null = {
source = "hashicorp/null"
version = "3.2.1"
}
EOF
required_provider_github = <<EOF
github = {
source = "integrations/github"
version = "~> 5.0"
}
EOF
}
generate "terraform" {
path = "terraform.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
terraform {
required_version = "${local.terraform_version}"
required_providers {
${local.required_provider_azure}
${local.required_provider_null}
${local.required_provider_external}
}
}
EOF
}
remote_state {
backend = "azurerm"
config = {
resource_group_name = get_env("MGMT_RG")
storage_account_name = get_env("MGMT_STORAGE")
container_name = get_env("STATE_CONTAINER")
key = "${path_relative_to_include()}/terraform.tfstate"
}
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
}
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = local.azure_provider
}
# Here we define common variables to be inhereted by each module (as long as they're set in its variables.tf)
inputs = {
location = get_env("LOCATION")
naming_suffix = get_env("NAMING_SUFFIX")
truncated_naming_suffix = get_env("TRUNCATED_NAMING_SUFFIX")
environment = get_env("ENVIRONMENT")
deployer_ip_address = get_env("DEPLOYER_IP_ADDRESS", "") # deployer's IP address is added to resource firewall exceptions IF in local_mode
local_mode = get_env("LOCAL_MODE", false)
core_address_space = get_env("CORE_ADDRESS_SPACE")
tags = {
environment = get_env("ENVIRONMENT")
}
}