我正在尝试运行 terraform。这是我的 main.tf
provider "aws" { region = "eu-central-1"}
resource "aws_instance" "example" {
ami = "ami-df8403b0"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.instance.id}"]
user_data = <<-EOF
#!/bin/bash
echo "Hello, World" > index.html
nohup busybox httpd -f -p "${var.server_port}" &
EOF
tags {
Name = "terraform-example"
}
}
variable "server_port" {
description = "The port the server will use for HTTP requests"
default = 8080
}
resource "aws_security_group" "instance" {
name = "terraform-example-instance"
ingress {
from_port = "${var.server_port}"
to_port = "${var.server_port}"
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
如果我想检查依赖图,这就是我得到的
无法加载根配置模块:解析 /home/milenko/brikman/main.tf 时出错:在 41:1:heredoc 未终止
HCL 解析器对空格敏感,因此请确保混合中没有制表符。还要确保在 EOF 和 tags 语句之间有一个换行符。