请帮助了解如何从不同位置导入变量文件?我试着从模块系统中做到这一点,但它对我不起作用
我的结构:
/
/variables.tf
/my_ec2/main.tf
/my_ec2/variables.tf
如何从根文件夹导入变量?需要在main.tf 上以某种方式指定
My/My_ec2/main.tf
module "global_vars" {
source = "../../../"
}
provider "aws" {
region = "module.global_vars.region_aws"
}
my/variables.tf
variable "region_aws" {
default = "eu-central-1"
}
我该怎么做?P.S.对"${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.
可能使用:
"${module.global_vars.region_aws}"
代替
"module.global_vars.region_aws"