From 143ced11acf3ca282a45aa385288a50fb918280f Mon Sep 17 00:00:00 2001 From: Audun Nes Date: Mon, 11 Mar 2024 14:33:40 +0100 Subject: [PATCH] Add template for terragrunt --- tools/scaffolding/scripts/entrypoint.sh | 14 ++++++++++++- tools/scaffolding/templates/env.hcl.template | 21 +++++++++++++++++++ .../templates/terragrunt-root.hcl.template | 10 +++++++++ .../templates/terragrunt.hcl.template | 17 +++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tools/scaffolding/templates/env.hcl.template create mode 100644 tools/scaffolding/templates/terragrunt-root.hcl.template create mode 100644 tools/scaffolding/templates/terragrunt.hcl.template diff --git a/tools/scaffolding/scripts/entrypoint.sh b/tools/scaffolding/scripts/entrypoint.sh index bde17f9..80bb8cd 100755 --- a/tools/scaffolding/scripts/entrypoint.sh +++ b/tools/scaffolding/scripts/entrypoint.sh @@ -17,6 +17,13 @@ tf_module_output="/output/terraform/module.tf" tf_output_folders="/output/terraform" mkdir -p $tf_output_folders +# TERRAGRUNT +tg_root_template="/templates/terragrunt-root.hcl.template" +tg_env_template="/templates/env.hcl.template" +tg_local_template="/templates/terragrunt.hcl.template" +tg_output_folders="/output/terragrunt" +mkdir -p $tg_output_folders/test/database + # DOCKER docker_compose_template="/templates/compose.yml.template" docker_compose_output="/output/docker/compose.yml" @@ -53,4 +60,9 @@ python3 $scripts_path/generate_docker.py --docker-compose-template $docker_compo # TODO: generate pipeline # 5) Generate documentation -terraform-docs markdown --show "inputs" $source_module_path --output-file $documentation_output \ No newline at end of file +terraform-docs markdown --show "inputs" $source_module_path --output-file $documentation_output + +# 6) Generate terragrunt files +python3 $scripts_path/generate_tf_module.py --source-tf-doc $source_json_doc --temp-work-folder $generated_tf_module_data --tf-module-template $tg_local_template --tf-output-path $tg_output_folders/test/database/terragrunt.hcl +cp $tg_root_template $tg_output_folders/terragrunt.hcl +cp $tg_env_template $tg_output_folders/test/env.hcl diff --git a/tools/scaffolding/templates/env.hcl.template b/tools/scaffolding/templates/env.hcl.template new file mode 100644 index 0000000..fe21bb4 --- /dev/null +++ b/tools/scaffolding/templates/env.hcl.template @@ -0,0 +1,21 @@ +inputs = { + # Specify the staging environment. + # Valid Values: "dev", "test", "staging", "uat", "training", "prod". + # Notes: The value will set configuration defaults according to DFDS policies. + environment = "test" + + # Provide a cost centre for the resource. + # Valid Values: . + # Notes: This set the dfds.cost_centre tag. See recommendations [here](https://wiki.dfds.cloud/en/playbooks/standards/tagging_policy). + cost_centre = "example" +} + +generate "provider" { + path = "provider.tf" + if_exists = "overwrite_terragrunt" + contents = <