【发布时间】:2019-10-22 20:32:57
【问题描述】:
当我尝试为 AMI 使用数据块时出现以下错误:-
错误:module.ec2-wf.var.instance_type:模块 ec2-wf 中的变量 instance_type 应该是字符串类型,得到地图 错误:module.ec2-wf.var.ami:模块 ec2-wf 中的变量 ami 应该是字符串类型,得到地图 make: *** [验证] 错误 1
下面是我的 terraform 结构:-
project
modules
app1
app2
app3
common
global-variables.tf
main.tf
makefile
provider.tf
vpc.tf
global
acm
alb
asg
ec2
efs
lc
rds
redis
subapp
ec2
main.tf
makefile
provider.tf
variable.tf
project/modules/global/subapp/ec2/main.tf
module "ec2-wf" {
source = "../../../global/ec2"
name = "${var.name}"
db_remote_state_bucket = "s3-terraform-state"
db_remote_state_key = "subapp/ec2/terraform.tfstate"
key_name = "${lookup(var.key_name, terraform.workspace)}"
# ami = "${lookup(var.ami, terraform.workspace)}"
# instance_type = "${lookup(var.instance_type, terraform.workspace)}"
ami = "${var.ami}"
instance_type = "${var.instance_type}"
tags = {
Name = "${var.project}"
Environment = "${lookup(var.env, terraform.workspace)}"
}
}
项目/模块/global/ec2/variables.tf
variable "instance_type" {
description = "This describes the Map the environment whether it is dev/test/prd etc"
}
variable "ami" {
description = "This describes the Map of Availability Zones to deploy"
default = ""
}
【问题讨论】:
-
为这些变量传递的值是什么?该错误与为其中一个提供的默认值不一致,并且缺少为另一个提供的默认值。
标签: terraform