【发布时间】:2016-12-03 04:38:42
【问题描述】:
我无法通过私有 aws 密钥对连接 terraform 的 ssh 以进行厨师配置 - 错误看起来只是超时:
aws_instance.app (chef): Connecting to remote host via SSH...
aws_instance.app (chef): Host: 96.175.120.236:32:
aws_instance.app (chef): User: ubuntu
aws_instance.app (chef): Password: false
aws_instance.app (chef): Private key: true
aws_instance.app (chef): SSH Agent: true
aws_instance.app: Still creating... (5m30s elapsed)
Error applying plan:
1 error(s) occurred:
* dial tcp 96.175.120.236:32: i/o timeout
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
这是我的 terraform 计划 - 请注意 ssh 设置。key_name 设置设置为我的 AWS 密钥对名称,而 ssh_for_chef.pem 是私钥
variable "AWS_ACCESS_KEY" {}
variable "AWS_SECRET_KEY" {}
provider "aws" {
region = "us-east-1"
access_key = "${var.AWS_ACCESS_KEY}"
secret_key = "${var.AWS_SECRET_KEY}"
}
resource "aws_instance" "app" {
ami = "ami-88aa1ce0"
count = "1"
instance_type = "t1.micro"
key_name = "ssh_for_chef"
security_groups = ["sg-c43490e1"]
subnet_id = "subnet-75dd96e2"
associate_public_ip_address = true
provisioner "chef" {
server_url = "https://api.chef.io/organizations/xxxxxxx"
validation_client_name = "xxxxxxx-validator"
validation_key = "/home/user01/Documents/Devel/chef-repo/.chef/xxxxxxxx-validator.pem"
node_name = "dubba_u_7"
run_list = [ "motd_rhel" ]
user_name = "user01"
user_key = "/home/user01/Documents/Devel/chef-repo/.chef/user01.pem"
ssl_verify_mode = "false"
}
connection {
type = "ssh"
user = "ubuntu"
private_key = "${file("/home/user01/Documents/Devel/ssh_for_chef.pem")}"
}
}
有什么想法吗?
【问题讨论】:
-
您的安全组是否允许传入端口 22 访问?
-
是的,端口 22 允许进出。所有 AWS 值都在测试厨房中工作,所以我的 terraform 计划一定有问题,我错过了。
-
看来我需要弄清楚如何分配弹性ip
-
这是在 VPC 中吗?可能是网络 ACL 正在切断您的连接? (不要以为弹性IP会有什么不同,公网IP就够了)
-
想通了 - 只是一个阻止出站 ssh 的 ids 设备!
标签: ssh chef-infra terraform