Skip to content

Commit

Permalink
Merge pull request #33 from dfds/feature/cloudplatform/issues/2100
Browse files Browse the repository at this point in the history
Add template for terragrunt
  • Loading branch information
avnes authored Mar 11, 2024
2 parents 50b2754 + 143ced1 commit 5353f92
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tools/scaffolding/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
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
21 changes: 21 additions & 0 deletions tools/scaffolding/templates/env.hcl.template
Original file line number Diff line number Diff line change
@@ -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 = <<EOF
provider "aws" {
region = "eu-central-1"
}
EOF
}
10 changes: 10 additions & 0 deletions tools/scaffolding/templates/terragrunt-root.hcl.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
remote_state {
backend = "s3"
config {
bucket = "<your_bucket_name>-state-bucket"
encrypt = true
key = "${path_relative_to_include()}/terraform.tfstate"
region = "eu-central-1"
dynamodb_table = "terraform-locks"
}
}
17 changes: 17 additions & 0 deletions tools/scaffolding/templates/terragrunt.hcl.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
source = "git::https://github.com/dfds/terraform-aws-rds.git//?ref=$release"
}

# Include all settings from the parent terragrunt.hcl file
include "root" {
path = find_in_parent_folders()
}

# Include env.hcl for environment specific settings
include "env" {
path = find_in_parent_folders("env.hcl")
}

inputs = {
$inputs
}

0 comments on commit 5353f92

Please sign in to comment.