I am getting below error when I am trying to do use data block for AMI's:-
Error: module.ec2-wf.var.instance_type: variable instance_type in module ec2-wf should be type string, got map Error: module.ec2-wf.var.ami: variable ami in module ec2-wf should be type string, got map make: *** [validate] Error 1
Below is my terraform structure:-
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)}"
}
}
project/modules/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 = ""
}