在使用terraform和低于ia的代码创建堆栈时遇到此错误
错误:加载/root/terraform-stack-creation/main.tf时出错:位置2:10:资源后面必须紧跟两个字符串,即类型和名称
resource "aws_opsworks_stack" "stack" {
name = "${var.name}"
region = "${var.region}"
service_role_arn = "${var.service_role_arn}"
default_instance_profile_arn = "${var.instance_profile_arn}"
default_os = "Amazon Linux 2018.03"
configuration_manager_version = "11.10"
manage_berkshelf = false
default_root_device_type = "ebs"
use_opsworks_security_groups = false
vpc_id = "vpc-******************"
default_subnet_id = "subnet-*****************"
custom_json = "{}"
}
variable "name" {
type = "string"
description = "Name (Your required stack name)"
}
variable "region" {
type = list(string)
default = ["us-west-1a"]
description = "us-east-1,ap-south-1,ap-southeast-2,eu-central-1 (Give your region)"
}
variable "service_role_arn" {
type = list(string)
default = ["*********************"]
description = "Default IAM role"
}
variable "default_instance_profile_arn"{
type = list(string)
default = ["*************************"]
description = "Default IAM instance profile"
}
variable "default_availability_zone" {
type = "string"
description = "Give your availabity zone"
}
答案 0 :(得分:-1)
变量name
未设置任何内容。
您需要:
a)为name
b)通过environment variables,the command line,TF_INPUT=false
or -input=false
或其他方法设置name
变量