【发布时间】:2020-03-13 00:55:20
【问题描述】:
请帮助了解如何从其他位置导入变量文件? 我试图从模块系统中执行此操作,但它不适合我。
我的结构:
/
/variables.tf
/my_ec2/main.tf
/my_ec2/variables.tf
如何从根文件夹导入变量?需要在 main.tf 上以某种方式指定它
我的 /my_ec2/main.tf
module "global_vars" {
source = "../../../"
}
provider "aws" {
region = "module.global_vars.region_aws"
}
我的 /variables.tf
variable "region_aws" {
default = "eu-central-1"
}
我该怎么做? 附言对“${var.region_aws}”做了同样的事情,但结果相同
Error: Reference to undeclared input variable
on ../my_ec2/main.tf line 10, in resource "aws_instance" "server":
10: region = "${var.region_aws}"
An input variable with the name "aws_instance" has not been declared. This
variable can be declared with a variable "environment" {} block.
【问题讨论】:
-
当您说它对您不起作用时,您是否会收到错误或只是您没有预料到的行为?如果您遇到错误,您可以编辑您的问题以包含完整的错误输出吗?
标签: terraform terraform-provider-aws