diff --git a/terraform-hcl-standard/Makefile b/terraform-hcl-standard/Makefile deleted file mode 100644 index 7e3b6cdd..00000000 --- a/terraform-hcl-standard/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# --------------------------------------------------------- -# Root Makefile - orchestrate bootstrap modules -# --------------------------------------------------------- - -AWS_BOOTSTRAP_DIR = aws-cloud/bootstrap -BOOTSTRAP_S3_DIR = $(AWS_BOOTSTRAP_DIR)/state -BOOTSTRAP_DYNAMODB_DIR = $(AWS_BOOTSTRAP_DIR)/lock -BOOTSTRAP_IAM_DIR = $(AWS_BOOTSTRAP_DIR)/identity - -# -------------------------------------------- -# Bootstrap targets -# -------------------------------------------- - -bootstrap-init: - make -C $(BOOTSTRAP_S3_DIR) init - make -C $(BOOTSTRAP_DYNAMODB_DIR) init - make -C $(BOOTSTRAP_IAM_DIR) init - -bootstrap-apply: - make -C $(BOOTSTRAP_S3_DIR) apply - make -C $(BOOTSTRAP_DYNAMODB_DIR) apply - make -C $(BOOTSTRAP_IAM_DIR) apply - @echo "🎉 All bootstrap modules completed." - -# -------------------------------------------- -# Run all bootstraps in order -# -------------------------------------------- - -bootstrap-plan: - make -C $(BOOTSTRAP_S3_DIR) plan - make -C $(BOOTSTRAP_DYNAMODB_DIR) plan - make -C $(BOOTSTRAP_IAM_DIR) plan - - -bootstrap-output: - make -C $(BOOTSTRAP_S3_DIR) output - make -C $(BOOTSTRAP_DYNAMODB_DIR) output - make -C $(BOOTSTRAP_IAM_DIR) output - -bootstrap-destroy: - make -C $(BOOTSTRAP_S3_DIR) destroy - make -C $(BOOTSTRAP_DYNAMODB_DIR) destroy - make -C $(BOOTSTRAP_IAM_DIR) destroy - -bootstrap-reinit: bootstrap-destroy bootstrap diff --git a/terraform-hcl-standard/aws-cloud/bootstrap/Makefile b/terraform-hcl-standard/aws-cloud/bootstrap/Makefile new file mode 100644 index 00000000..795b8a7b --- /dev/null +++ b/terraform-hcl-standard/aws-cloud/bootstrap/Makefile @@ -0,0 +1,50 @@ +# --------------------------------------------------------- +# Bootstrap Makefile - orchestrate bootstrap modules +# --------------------------------------------------------- + +ifndef BOOTSTRAP_CONFIG_PATH +$(error BOOTSTRAP_CONFIG_PATH is required) +endif + +BOOTSTRAP_CONFIG_ABS := $(abspath $(BOOTSTRAP_CONFIG_PATH)) +BOOTSTRAP_ENV := BOOTSTRAP_CONFIG_PATH="$(BOOTSTRAP_CONFIG_ABS)" TF_VAR_bootstrap_config_path="$(BOOTSTRAP_CONFIG_ABS)" + +BOOTSTRAP_S3_DIR = state +BOOTSTRAP_DYNAMODB_DIR = lock +BOOTSTRAP_IAM_DIR = identity + +# -------------------------------------------- +# Bootstrap targets +# -------------------------------------------- + +bootstrap-init: + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_S3_DIR) init + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_DYNAMODB_DIR) init + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_IAM_DIR) init + +bootstrap-apply: + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_S3_DIR) apply + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_DYNAMODB_DIR) apply + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_IAM_DIR) apply + @echo "🎉 All bootstrap modules completed." + +# -------------------------------------------- +# Run all bootstraps in order +# -------------------------------------------- + +bootstrap-plan: + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_S3_DIR) plan + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_DYNAMODB_DIR) plan + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_IAM_DIR) plan + +bootstrap-output: + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_S3_DIR) output + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_DYNAMODB_DIR) output + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_IAM_DIR) output + +bootstrap-destroy: + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_S3_DIR) destroy + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_DYNAMODB_DIR) destroy + $(BOOTSTRAP_ENV) make -C $(BOOTSTRAP_IAM_DIR) destroy + +bootstrap-reinit: bootstrap-destroy bootstrap diff --git a/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl b/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl index 2959a69a..c551adad 100644 --- a/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl +++ b/terraform-hcl-standard/aws-cloud/bootstrap/identity/terragrunt.hcl @@ -10,17 +10,6 @@ terraform { source = "${get_parent_terragrunt_dir()}/..//bootstrap/identity" } -locals { - tg_root = get_env("TG_ROOT", get_parent_terragrunt_dir()) - repo_root = abspath("${local.tg_root}/../../../../../") - gitops_root = "${local.repo_root}/gitops" - - tf_config_env = trimspace(get_env("TF_CONFIG", "")) - bootstrap_config_path = local.tf_config_env != "" ? ( - startswith(local.tf_config_env, "/") ? local.tf_config_env : abspath("${local.repo_root}/${local.tf_config_env}") - ) : abspath("${local.gitops_root}/${get_env("GITOPS_BOOTSTRAP_CONFIG", "config/bootstrap.yaml")}") -} - inputs = { - bootstrap_config_path = local.bootstrap_config_path + bootstrap_config_path = get_env("BOOTSTRAP_CONFIG_PATH", "") } diff --git a/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl b/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl index eac8b74b..3d2b31ff 100644 --- a/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl +++ b/terraform-hcl-standard/aws-cloud/bootstrap/lock/terragrunt.hcl @@ -10,17 +10,6 @@ terraform { source = "${get_parent_terragrunt_dir()}/..//bootstrap/lock" } -locals { - tg_root = get_env("TG_ROOT", get_parent_terragrunt_dir()) - repo_root = abspath("${local.tg_root}/../../../../../") - gitops_root = "${local.repo_root}/gitops" - - tf_config_env = trimspace(get_env("TF_CONFIG", "")) - bootstrap_config_path = local.tf_config_env != "" ? ( - startswith(local.tf_config_env, "/") ? local.tf_config_env : abspath("${local.repo_root}/${local.tf_config_env}") - ) : abspath("${local.gitops_root}/${get_env("GITOPS_BOOTSTRAP_CONFIG", "config/bootstrap.yaml")}") -} - inputs = { - bootstrap_config_path = local.bootstrap_config_path + bootstrap_config_path = get_env("BOOTSTRAP_CONFIG_PATH", "") } diff --git a/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl b/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl index b0446eed..91d9129d 100644 --- a/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl +++ b/terraform-hcl-standard/aws-cloud/bootstrap/state/terragrunt.hcl @@ -6,17 +6,6 @@ terraform { source = "${get_parent_terragrunt_dir()}/..//bootstrap/state" } -locals { - tg_root = get_env("TG_ROOT", get_parent_terragrunt_dir()) - repo_root = abspath("${local.tg_root}/../../../../../") - gitops_root = "${local.repo_root}/gitops" - - tf_config_env = trimspace(get_env("TF_CONFIG", "")) - bootstrap_config_path = local.tf_config_env != "" ? ( - startswith(local.tf_config_env, "/") ? local.tf_config_env : abspath("${local.repo_root}/${local.tf_config_env}") - ) : abspath("${local.gitops_root}/${get_env("GITOPS_BOOTSTRAP_CONFIG", "config/bootstrap.yaml")}") -} - inputs = { - bootstrap_config_path = local.bootstrap_config_path + bootstrap_config_path = get_env("BOOTSTRAP_CONFIG_PATH", "") }