【发布时间】:2017-05-17 20:13:12
【问题描述】:
我通过 terraform 在 aws 中创建了一个自定义 vpc,其中包含 1 个公共子网和 2 个私有子网。现在我需要通过 Terraform 在私有子网中启动一个运行 apache 的实例。我在私有子网中启动一个实例的代码是这样的
resource "aws_instance" "my_apache" {
ami = "ami-8437a5e4"
key_name = "clust"
subnet_id = "${aws_subnet.my_private1.id}"
vpc_security_group_ids = ["sg-40542d3b"]
availability_zone = "us-west-2a"
instance_type = "t2.micro"
tags {
Name = "apache"
}
provisioner "remote-exec" {
inline = [
"sudo apt-get update",
"sudo apt-get install apache2",
"sudo service apache2 start"
]
}
}
实例正在启动,但 apache 服务器未在实例中运行。我收到类似 dis 的错误。
aws_instance.my_apache (remote-exec): Connecting to remote host via SSH...
aws_instance.my_apache (remote-exec): Host: 172.16.2.163
aws_instance.my_apache (remote-exec): User: root
aws_instance.my_apache (remote-exec): Password: false
aws_instance.my_apache (remote-exec): Private key: false
aws_instance.my_apache (remote-exec): SSH Agent: true
aws_instance.my_apache: Still creating... (3m0s elapsed)
^CInterrupt received. Gracefully shutting down...
aws_instance.my_apache: Still creating... (3m10s elapsed)
aws_instance.my_apache (remote-exec): Connecting to remote host via SSH...
aws_instance.my_apache (remote-exec): Host: 172.16.2.163
aws_instance.my_apache (remote-exec): User: root
aws_instance.my_apache (remote-exec): Password: false
aws_instance.my_apache (remote-exec): Private key: false
aws_instance.my_apache (remote-exec): SSH Agent: true
它一直在继续。
可能是什么问题?如何让 apache 在该实例中运行?
【问题讨论】:
-
您在运行 terraform 的地方有什么样的连接?看起来它无权访问私有子网以连接到您的实例以运行配置
标签: amazon-web-services terraform