-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathterragrunt.hcl
88 lines (76 loc) · 2.1 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
# configure terragrunt behaviours with these
locals {
ENVIRONMENT_NAME = get_env("ENVIRONMENT_NAME", "development")
config = yamldecode(file("./environments/${ get_env("ENVIRONMENT_NAME", "development") }/config.yaml"))
default_outputs = {}
}
generate "aws-provider" {
path = "provider.tf"
if_exists = "overwrite"
contents = <<EOF
provider "aws" {
profile = "${ chomp(get_env("AWS_PROFILE", "default")) }"
region = "${ chomp(try(local.config.general.region, "eu-west-1")) }"
#alias = "terragrunt"
default_tags {
tags = {
Environment = "${ chomp(try(local.ENVIRONMENT_NAME)) }"
Project = "${ chomp(try(local.config.general.project, "default")) }"
}
}
}
%{ for region in try(local.config.general.regions, { } ) ~}
provider "aws" {
profile = "${ chomp(get_env("AWS_PROFILE", "default")) }"
region = "${region}"
alias = "${region}"
default_tags {
tags = {
Environment = "${ chomp(try(local.ENVIRONMENT_NAME)) }"
Project = "${ chomp(try(local.config.general.project, "default")) }"
}
}
}
%{ endfor ~}
EOF
}
generate "terraform-tf" {
path = "terraform.tf"
if_exists = "overwrite"
contents = <<EOF
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.76.0"
}
template = {
source = "cloudposse/template"
version = "~> 2.2.0"
}
kubectl = {
source = "alekc/kubectl"
version = ">= 2.0.2"
}
}
}
EOF
}
remote_state {
backend = "s3"
generate = {
path = "backend.tf"
if_exists = "overwrite"
}
config = {
bucket = "${local.config.general.env-short}-${local.config.general.project}-tfstate"
region = "${ chomp(try(local.config.general.region, "eu-west-1")) }"
encrypt = true
key = "${ get_env("ENVIRONMENT_NAME", "development") }/${basename(get_terragrunt_dir())}/terraform.tfstate"
dynamodb_table = "${local.config.general.env-short}-${local.config.general.project}-tfstate"
profile = "${ get_env("AWS_PROFILE", "default") }"
}
}
terraform {
source = "../../tg-modules//empty-module"
}