Simplify bootstrap orchestration
This commit is contained in:
parent
60166ede66
commit
a4db6e2e13
@ -1,10 +1,10 @@
|
||||
locals {
|
||||
bootstrap = var.bootstrap
|
||||
bootstrap = yamldecode(file("${path.module}/../../config/accounts/bootstrap.yaml"))
|
||||
|
||||
config_account_name = coalesce(var.account_name, try(local.bootstrap.account_name, null))
|
||||
config_region = coalesce(var.region, try(local.bootstrap.region, null))
|
||||
config_role_name = coalesce(var.role_name, try(local.bootstrap.iam.role_name, null))
|
||||
config_terraform_user = coalesce(var.terraform_user_name, try(local.bootstrap.iam.terraform_user_name, null))
|
||||
config_account_name = coalesce(var.account_name, local.bootstrap.account_name)
|
||||
config_region = coalesce(var.region, local.bootstrap.region)
|
||||
config_role_name = coalesce(var.role_name, local.bootstrap.iam.role_name)
|
||||
config_terraform_user = coalesce(var.terraform_user_name, local.bootstrap.iam.terraform_user_name)
|
||||
environment = coalesce(try(local.bootstrap.environment, null), try(local.bootstrap.iam.environment, null), "bootstrap")
|
||||
extra_tags = try(local.bootstrap.tags, {})
|
||||
|
||||
@ -15,8 +15,9 @@ locals {
|
||||
}
|
||||
|
||||
locals {
|
||||
account = length(var.account) > 0 ? var.account : {
|
||||
account_id = try(local.bootstrap.account_id, null)
|
||||
account_file_path = "${path.module}/../../../config/accounts/${local.config_account_name}.yaml"
|
||||
account = fileexists(local.account_file_path) ? yamldecode(file(local.account_file_path)) : {
|
||||
account_id = local.bootstrap.account_id
|
||||
environment = local.environment
|
||||
tags = local.extra_tags
|
||||
}
|
||||
|
||||
@ -2,47 +2,10 @@ include "root" {
|
||||
path = find_in_parent_folders()
|
||||
}
|
||||
|
||||
locals {
|
||||
root_config = read_terragrunt_config(find_in_parent_folders())
|
||||
bootstrap_config = local.root_config.locals.bootstrap_config
|
||||
account_file = find_in_parent_folders("config/accounts/${local.bootstrap_config.account_name}.yaml", "")
|
||||
account_config = fileexists(local.account_file) ? yamldecode(file(local.account_file)) : {
|
||||
account_id = local.bootstrap_config.account_id
|
||||
environment = try(local.bootstrap_config.environment, "bootstrap")
|
||||
tags = try(local.bootstrap_config.tags, {})
|
||||
}
|
||||
}
|
||||
|
||||
dependency "state" {
|
||||
config_path = "../state"
|
||||
|
||||
mock_outputs = {
|
||||
bucket_name = local.bootstrap_config.state.bucket_name
|
||||
region = local.bootstrap_config.region
|
||||
}
|
||||
|
||||
mock_outputs_allowed_terraform_commands = ["plan", "validate"]
|
||||
}
|
||||
|
||||
dependency "lock" {
|
||||
config_path = "../lock"
|
||||
|
||||
mock_outputs = {
|
||||
dynamodb_table_name = local.bootstrap_config.state.dynamodb_table_name
|
||||
region = local.bootstrap_config.region
|
||||
}
|
||||
|
||||
mock_outputs_allowed_terraform_commands = ["plan", "validate"]
|
||||
dependencies {
|
||||
paths = ["../state", "../lock"]
|
||||
}
|
||||
|
||||
terraform {
|
||||
source = "./"
|
||||
}
|
||||
|
||||
inputs = {
|
||||
region = dependency.state.outputs.region
|
||||
state_bucket_name = dependency.state.outputs.bucket_name
|
||||
state_lock_table_name = dependency.lock.outputs.dynamodb_table_name
|
||||
bootstrap = local.bootstrap_config
|
||||
account = local.account_config
|
||||
source = "${get_parent_terragrunt_dir()}/..//bootstrap/identity"
|
||||
}
|
||||
|
||||
@ -73,15 +73,3 @@ variable "state_lock_table_name" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "bootstrap" {
|
||||
description = "Bootstrap configuration provided by Terragrunt"
|
||||
type = map(any)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "account" {
|
||||
description = "Resolved account configuration provided by Terragrunt"
|
||||
type = map(any)
|
||||
default = {}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
locals {
|
||||
bootstrap = var.bootstrap
|
||||
bootstrap = yamldecode(file("${path.module}/../../config/accounts/bootstrap.yaml"))
|
||||
|
||||
dynamodb_table_name = coalesce(var.table_name, local.bootstrap.state.dynamodb_table_name)
|
||||
region = coalesce(var.region, local.bootstrap.region)
|
||||
|
||||
@ -2,27 +2,10 @@ include "root" {
|
||||
path = find_in_parent_folders()
|
||||
}
|
||||
|
||||
locals {
|
||||
root_config = read_terragrunt_config(find_in_parent_folders())
|
||||
bootstrap_config = local.root_config.locals.bootstrap_config
|
||||
}
|
||||
|
||||
dependency "state" {
|
||||
config_path = "../state"
|
||||
|
||||
mock_outputs = {
|
||||
bucket_name = local.bootstrap_config.state.bucket_name
|
||||
region = local.bootstrap_config.region
|
||||
}
|
||||
|
||||
mock_outputs_allowed_terraform_commands = ["plan", "validate"]
|
||||
dependencies {
|
||||
paths = ["../state"]
|
||||
}
|
||||
|
||||
terraform {
|
||||
source = "./"
|
||||
}
|
||||
|
||||
inputs = {
|
||||
region = dependency.state.outputs.region
|
||||
bootstrap = local.bootstrap_config
|
||||
source = "${get_parent_terragrunt_dir()}/..//bootstrap/lock"
|
||||
}
|
||||
|
||||
@ -9,9 +9,3 @@ variable "region" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "bootstrap" {
|
||||
description = "Bootstrap configuration provided by Terragrunt"
|
||||
type = map(any)
|
||||
default = {}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
locals {
|
||||
bootstrap = var.bootstrap
|
||||
bootstrap = yamldecode(file("${path.module}/../../config/accounts/bootstrap.yaml"))
|
||||
|
||||
bucket_name = coalesce(var.bucket_name, local.bootstrap.state.bucket_name)
|
||||
region = coalesce(var.region, local.bootstrap.region)
|
||||
|
||||
@ -2,17 +2,6 @@ include "root" {
|
||||
path = find_in_parent_folders()
|
||||
}
|
||||
|
||||
locals {
|
||||
root_config = read_terragrunt_config(find_in_parent_folders())
|
||||
bootstrap_config = local.root_config.locals.bootstrap_config
|
||||
}
|
||||
|
||||
terraform {
|
||||
source = "./"
|
||||
}
|
||||
|
||||
inputs = {
|
||||
bucket_name = local.bootstrap_config.state.bucket_name
|
||||
region = local.bootstrap_config.region
|
||||
bootstrap = local.bootstrap_config
|
||||
source = "${get_parent_terragrunt_dir()}/..//bootstrap/state"
|
||||
}
|
||||
|
||||
@ -9,9 +9,3 @@ variable "region" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "bootstrap" {
|
||||
description = "Bootstrap configuration provided by Terragrunt"
|
||||
type = map(any)
|
||||
default = {}
|
||||
}
|
||||
|
||||
@ -2,5 +2,5 @@ terraform_version_constraint = ">= 1.2.0"
|
||||
terragrunt_version_constraint = ">= 0.67.14"
|
||||
|
||||
locals {
|
||||
bootstrap_config = yamldecode(file(find_in_parent_folders("config/accounts/bootstrap.yaml")))
|
||||
bootstrap_config = yamldecode(file("${get_original_terragrunt_dir()}/../config/accounts/bootstrap.yaml"))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user