平台之间共享基础架构的terragrunt

时间:2019-06-26 07:15:53

标签: terraform terragrunt

directory structure

我正在使用s3作为远程状态后端和dynamodb表进行锁定

platform1和platform2都使用共享平台中的共享基础结构

如果我首先尝试创建platform1,则由于未创建共享中的依赖关系而将失败,与platform2相同,但是如果我先创建共享平台,然后再创建platform1和platform2,则所有基础架构都将建立而没有问题

这是正确的吗? 尝试构建平台环境之一时,如何首先构建共享环境?

我尝试过首先创建共享环境

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"
}
platform1内的

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

0 个答案:

没有答案