【发布时间】:2020-02-04 01:21:25
【问题描述】:
我正在尝试使用 2-repo IaC,所谓的后端采用 terragrunt 模块的形式,前端(或 live)具有正在填充的此类模块的实例化在变量中。
下图描述了这 2 个 repos 的结构(terragrunt 是后端,terraform-live 顾名思义是实时的)。
在我的terragrunt/aws-vpc/variables.tf,有如下声明:
variable "remote_state_bucket" {
description = "The bucket containing the terraform remote state"
}
但是,当尝试在 live 目录中执行 terragrunt apply 时,我得到以下信息:
var.remote_state_bucket
The bucket containing the terraform remote state
Enter a value:
这是我的terraform-live/environments/staging/terragrunt.hcl
remote_state {
backend = "s3"
config = {
bucket = "my-bucket-staging"
key = "terraform/state/var.env_name/${path_relative_to_include()}"
region = "eu-west-1"
}
}
# Configure root level variables that all resources can inherit
terraform {
extra_arguments "extra_args" {
commands = "${get_terraform_commands_that_need_vars()}"
optional_var_files = [
"${get_terragrunt_dir()}/${find_in_parent_folders("config.tfvars", "ignore")}",
"${get_terragrunt_dir()}/${find_in_parent_folders("secrets.auto.tfvars", "ignore")}",
]
}
}
更重要的是,该变量似乎是在terragrunt被指示从以下文件中读取变量的文件之一中声明的:
➢ cat terraform-live/environments/staging/config.tfvars
remote_state_bucket = "pkaramol-staging"
为什么terragrunt(或terraform?)无法读取特定变量?
➢ terragrunt --version
terragrunt version v0.19.29
➢ terraform --version
Terraform v0.12.4
【问题讨论】:
标签: terraform infrastructure-as-code terragrunt