-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: extra_atlantis_dependencies using project-hcl-files
- Loading branch information
Showing
14 changed files
with
274 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
automerge: false | ||
parallel_apply: true | ||
parallel_plan: true | ||
projects: | ||
- autoplan: | ||
enabled: false | ||
when_modified: | ||
- '*.hcl' | ||
- '*.tf*' | ||
- '**/*.hcl' | ||
- '**/*.tf*' | ||
- ../../../terragrunt.hcl | ||
- ../../account.hcl | ||
- ../region.hcl | ||
- ../../arbitrary.hcl | ||
- ../stage/**/*.hcl | ||
- internaldep/*.json | ||
- ../../../externaldep.hcl | ||
dir: non-prod/us-east-1/qa | ||
workflow: anotherWorkflowSpecifiedInParent | ||
version: 3 |
3 changes: 3 additions & 0 deletions
3
test_examples/project_hcl_with_project_marker_reldep/externaldep.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
locals{ | ||
key = "value" | ||
} |
7 changes: 7 additions & 0 deletions
7
test_examples/project_hcl_with_project_marker_reldep/non-prod/account.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Set account-wide variables. These are automatically pulled in to configure the remote state bucket in the root | ||
# terragrunt.hcl configuration. | ||
locals { | ||
account_name = "non-prod" | ||
aws_account_id = "replaceme" # TODO: replace me with your AWS account ID! | ||
aws_profile = "non-prod" | ||
} |
3 changes: 3 additions & 0 deletions
3
test_examples/project_hcl_with_project_marker_reldep/non-prod/arbitrary.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
locals { | ||
some = "stuff" | ||
} |
13 changes: 13 additions & 0 deletions
13
test_examples/project_hcl_with_project_marker_reldep/non-prod/us-east-1/qa/environment.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Set common variables for the environment. This is automatically pulled in in the root terragrunt.hcl configuration to | ||
# feed forward to the child modules. | ||
locals { | ||
environment = "qa" | ||
extra_atlantis_dependencies = [ | ||
find_in_parent_folders("arbitrary.hcl"), | ||
"${dirname(find_in_parent_folders("account.hcl"))}/us-east-1/stage/**/*.hcl", | ||
"./internaldep/*.json", | ||
"../../../externaldep.hcl", | ||
] | ||
atlantis_workflow = "anotherWorkflowSpecifiedInParent" | ||
atlantis_project = true | ||
} |
1 change: 1 addition & 0 deletions
1
...es/project_hcl_with_project_marker_reldep/non-prod/us-east-1/qa/internaldep/whatever.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"key": "value"} |
31 changes: 31 additions & 0 deletions
31
...xamples/project_hcl_with_project_marker_reldep/non-prod/us-east-1/qa/mysql/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
locals { | ||
# Automatically load environment-level variables | ||
environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl")) | ||
|
||
# Extract out common variables for reuse | ||
env = local.environment_vars.locals.environment | ||
} | ||
|
||
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the | ||
# working directory, into a temporary folder, and execute your Terraform commands in that folder. | ||
terraform { | ||
source = "git::git@github.com:gruntwork-io/terragrunt-infrastructure-modules-example.git//mysql?ref=v0.3.0" | ||
} | ||
|
||
# Include all settings from the root terragrunt.hcl file | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above | ||
inputs = { | ||
name = "mysql_${local.env}" | ||
instance_class = "db.t2.micro" | ||
|
||
allocated_storage = 20 | ||
storage_type = "standard" | ||
|
||
master_username = "admin" | ||
# TODO: To avoid storing your DB password in the code, set it as the environment variable TF_VAR_master_password | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
...ect_hcl_with_project_marker_reldep/non-prod/us-east-1/qa/webserver-cluster/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
locals { | ||
# Automatically load environment-level variables | ||
environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl")) | ||
|
||
# Extract out common variables for reuse | ||
env = local.environment_vars.locals.environment | ||
} | ||
|
||
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the | ||
# working directory, into a temporary folder, and execute your Terraform commands in that folder. | ||
terraform { | ||
source = "git::git@github.com:gruntwork-io/terragrunt-infrastructure-modules-example.git//asg-elb-service?ref=v0.3.0" | ||
} | ||
|
||
# Include all settings from the root terragrunt.hcl file | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above | ||
inputs = { | ||
name = "webserver-example-${local.env}" | ||
instance_type = "t2.micro" | ||
|
||
min_size = 2 | ||
max_size = 2 | ||
|
||
server_port = 8080 | ||
elb_port = 80 | ||
} |
5 changes: 5 additions & 0 deletions
5
test_examples/project_hcl_with_project_marker_reldep/non-prod/us-east-1/region.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Set common variables for the region. This is automatically pulled in in the root terragrunt.hcl configuration to | ||
# configure the remote state bucket and pass forward to the child modules as inputs. | ||
locals { | ||
aws_region = "us-east-1" | ||
} |
72 changes: 72 additions & 0 deletions
72
test_examples/project_hcl_with_project_marker_reldep/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# TERRAGRUNT CONFIGURATION | ||
# Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules, | ||
# remote state, and locking: https://github.com/gruntwork-io/terragrunt | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
locals { | ||
extra_atlantis_dependencies = [ | ||
find_in_parent_folders("account.hcl"), | ||
find_in_parent_folders("region.hcl"), | ||
find_in_parent_folders("environment.hcl"), | ||
] | ||
|
||
# Automatically load account-level variables | ||
account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl")) | ||
|
||
# Automatically load region-level variables | ||
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl")) | ||
|
||
# Automatically load environment-level variables | ||
environment_vars = read_terragrunt_config(find_in_parent_folders("environment.hcl")) | ||
|
||
# Extract the variables we need for easy access | ||
account_name = local.account_vars.locals.account_name | ||
account_id = local.account_vars.locals.aws_account_id | ||
aws_region = local.region_vars.locals.aws_region | ||
} | ||
|
||
# Generate an AWS provider block | ||
generate "provider" { | ||
path = "provider.tf" | ||
if_exists = "overwrite_terragrunt" | ||
contents = <<EOF | ||
provider "aws" { | ||
region = "${local.aws_region}" | ||
# Only these AWS Account IDs may be operated on by this template | ||
allowed_account_ids = ["${local.account_id}"] | ||
} | ||
EOF | ||
} | ||
|
||
# Configure Terragrunt to automatically store tfstate files in an S3 bucket | ||
remote_state { | ||
backend = "s3" | ||
config = { | ||
encrypt = true | ||
bucket = "${get_env("TG_BUCKET_PREFIX", "")}terragrunt-example-terraform-state-${local.account_name}-${local.aws_region}" | ||
key = "${path_relative_to_include()}/terraform.tfstate" | ||
region = local.aws_region | ||
dynamodb_table = "terraform-locks" | ||
} | ||
generate = { | ||
path = "backend.tf" | ||
if_exists = "overwrite_terragrunt" | ||
} | ||
} | ||
|
||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GLOBAL PARAMETERS | ||
# These variables apply to all configurations in this subfolder. These are automatically merged into the child | ||
# `terragrunt.hcl` config via the include block. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
# Configure root level variables that all resources can inherit. This is especially helpful with multi-account configs | ||
# where terraform_remote_state data sources are placed directly into the modules. | ||
inputs = merge( | ||
local.account_vars.locals, | ||
local.region_vars.locals, | ||
local.environment_vars.locals, | ||
) |