Skip to content

Commit 7a9378b

Browse files
committed
infra: modified terragrunt config to use aws_profile as defined
1 parent 2c6428b commit 7a9378b

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

scripts/aws/lambda/TM-Extractor/dev/env.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
locals {
55
environment = "dev"
66
account_name = "naxadevelopers"
7+
aws_profile = "default"
78
aws_region = "ap-south-1"
89
application = "tasking-manager"
910
team = "HOTOSM"

scripts/aws/lambda/TM-Extractor/prod/env.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
locals {
55
environment = "prod"
66
account_name = "hotosm"
7+
aws_profile = "default"
78
aws_region = "ap-south-1"
89
application = "tasking-manager"
910
team = "HOTOSM"

scripts/aws/lambda/TM-Extractor/stag/env.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
locals {
55
environment = "stag"
66
account_name = "hotosm"
7+
aws_profile = "default"
78
aws_region = "ap-south-1"
89
application = "tasking-manager"
910
team = "HOTOSM"

scripts/aws/lambda/TM-Extractor/terragrunt.hcl

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ locals {
1010

1111
# Extract the variables we need for easy access
1212
account_name = local.environment_vars.locals.account_name
13+
aws_profile = local.environment_vars.locals.aws_profile
1314
aws_region = local.environment_vars.locals.aws_region
1415
environment = local.environment_vars.locals.environment
1516
application = local.environment_vars.locals.application
@@ -23,21 +24,39 @@ generate "provider" {
2324
path = "provider.tf"
2425
if_exists = "overwrite_terragrunt"
2526
contents = <<EOF
26-
provider "aws" {
27-
region = "${local.aws_region}"
27+
provider "aws" {
28+
region = "${local.aws_region}"
29+
profile = "${local.aws_profile}"
30+
default_tags {
31+
tags = {
32+
Environment = "${local.environment}"
33+
Application = "${local.application}"
34+
Team = "${local.team}"
35+
Creator = "${local.creator}"
36+
Owner = "${local.owner}"
37+
}
38+
}
39+
}
40+
EOF
41+
}
2842

29-
default_tags {
30-
tags = {
31-
Environment = "${local.environment}"
32-
Application = "${local.application}"
33-
Team = "${local.team}"
34-
Creator = "${local.creator}"
35-
Owner = "${local.owner}"
43+
#Export AWS_PROFILE env var.
44+
terraform {
45+
extra_arguments "aws_profile" {
46+
commands = [
47+
"init",
48+
"apply",
49+
"refresh",
50+
"import",
51+
"plan",
52+
"destroy"
53+
]
54+
55+
env_vars = {
56+
AWS_PROFILE = "${local.aws_profile}"
3657
}
3758
}
3859
}
39-
EOF
40-
}
4160

4261
# Configure Terragrunt to automatically store tfstate files in an S3 bucket
4362
remote_state {
@@ -48,6 +67,7 @@ remote_state {
4867
key = "${path_relative_to_include()}/terraform.tfstate"
4968
region = local.aws_region
5069
dynamodb_table = "tm-extractor-locks"
70+
profile = "${local.aws_profile}"
5171
}
5272
generate = {
5373
path = "backend.tf"

0 commit comments

Comments
 (0)