2

目录结构

我使用 s3 作为远程状态后端和用于锁定的 dynamodb 表

platform1 和 platform2 都使用来自共享平台的共享基础架构

如果我首先尝试创建平台 1,它将失败,因为尚未创建共享中的依赖项,平台 2 也是如此,但如果我先创建共享平台,然后创建平台 1 和平台 2,所有基础设施都将毫无问题地构建

这个对吗?尝试构建其中一个平台环境时,如何首先构建共享环境?

我尝试过先创建共享环境

根 terragrunt.hcl 文件,即 tst1 文件夹下

# 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"
}

平台1内的terragrunt.hcl

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 = {
...
...
...
}

4

0 回答 0