terragrunt with shared infrastrucure between platforms

Viewed 424

directory structure

I am using s3 as remote state backend and dynamodb table for locking

Both platform1 and platform2 used share infrastructure from shared platform

If I try to create platform1 first it will fail as the dependencies in shared haven’t been created, same for platform2, but if I create shared platform first and then platform1 and platform2 all infrastructure will build without issues

Is this correct? How can I build shared environment first when trying to build one of the platform environments?

I have tried creating shared environment first

the root terragrunt.hcl file i.e. under tst1 folder

# Configure Terragrunt to automatically store tfstate files in an S3 bucket
remote_state {
  backend = "s3"

  config = {
      encrypt        = true
      bucket         = "automation-terraform-state"
      key            = "tst1/${path_relative_to_include()}/terraform.tfstate"
      region         = "ap-southeast-2"
      dynamodb_table = "tst-terraform-locks"
  }
}

# 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 = {
  aws_region            = "ap-southeast-2"
  ami_id                = "ami-0aa5848a455c3ec32"
  vpc_id                = "vpc-7e49e81a"
}

terragrunt.hcl inside platform1

terraform {
  source = "git::git@github.com:acme/infrastructure-modules.git//application_lb"
}

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

inputs = {
...
...
...
}

0 Answers
Related