EC2 创建中的 Provisioner 部分导致 Terraform 应用失败

Provisioner sections in EC2 creation causing Terraform apply to fail

我是 运行 来自本地计算机的 Terraform,通过堡垒机创建 Amazon Linux EC2。

当我在我的 "aws_instance" 资源中包含供应商条目时出现问题。没有配置器,创建成功完成

使用供应商 "file" 部分我得到错误:

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain

使用供应商 "remote-exec" 部分,我得到以下不断重复直到超时:

module.create_ami.aws_instance.ec2 (remote-exec): Connecting to remote host via SSH...
module.create_ami.aws_instance.ec2 (remote-exec):   Host: 99.999.999.99
module.create_ami.aws_instance.ec2 (remote-exec):   User: ec2-user
module.create_ami.aws_instance.ec2 (remote-exec):   Password: false
module.create_ami.aws_instance.ec2 (remote-exec):   Private key: false
module.create_ami.aws_instance.ec2 (remote-exec):   SSH Agent: false
module.create_ami.aws_instance.ec2 (remote-exec): Using configured bastion host...

有谁知道为什么会发生这种情况或建议进行调查?

Remote-exec is not able to ssh into the target system, as the output says- Private key:false

我相信你不需要通过堡垒机来创建一台ec2机器,你甚至可以连接到本地机器。

如果你想在有一个 public IP 的新创建的机器上使用 remote exec,你可以直接连接它,如果新创建的机器没有一个 public IP , 然后就可以通过堡垒机连接了。