-
Notifications
You must be signed in to change notification settings - Fork 0
/
terragrunt.hcl
76 lines (64 loc) · 2.36 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
locals {
global_vars = read_terragrunt_config(find_in_parent_folders("globals.hcl"))
env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) # This works because find_in_parent_folders always works at the context of the child configuration.
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
service_vars = read_terragrunt_config(find_in_parent_folders("service.hcl", "fallback.hcl"), { locals = { tags = {} } })
vars = merge(local.global_vars.locals, local.env_vars.locals, local.region_vars.locals, local.service_vars.locals)
namespace = local.vars.namespace
environment = local.vars.environment
tags = {
Application = format("%s-%s-%s-%s", local.vars.namespace, local.vars.tenant, local.vars.environment, local.vars.name)
}
}
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
provider "aws" {
region = "${local.vars.region}"
# AWS Account ID allowed to execute the terragrunt commands
allowed_account_ids = ["${get_aws_account_id()}"]
}
EOF
}
terraform {
extra_arguments "global_args" {
commands = get_terraform_commands_that_need_locking()
arguments = ["-lock-timeout=30m", "-input=false"]
}
extra_arguments "plan_args" {
commands = ["plan"]
arguments = tolist(["-compact-warnings", "-refresh=true", "-out=${get_env("PLANFILE", "tfplan")}"])
}
extra_arguments "apply_args" {
commands = ["apply"]
arguments = tolist([get_env("PLANFILE", "tfplan")])
}
}
remote_state {
backend = "s3"
config = {
encrypt = false
region = "eu-west-1"
bucket = "terraform-state"
key = "${path_relative_to_include()}/terraform.tfstate"
dynamodb_table = "terraform-locks"
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
}
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
}
inputs = {
label_order = local.vars.label_order
namespace = local.vars.namespace
tenant = local.tenant
environment = local.vars.environment
stage = local.vars.stage
name = local.vars.name
region = local.vars.region
tags = merge(local.tags, local.global_vars.locals.tags, local.env_vars.locals.tags, local.region_vars.locals.tags, local.service_vars.locals.tags)
}