Terrafrom-连接问题

时间:2019-06-05 07:38:05

标签: amazon-web-services ssh connection terraform ssh-keys

我正在尝试使用Terrafrom通过堡垒服务器连接到私有ec2实例。但是Terrafrom脚本会问“您确定要继续连接(是/否)吗?”的问题。而且我无法通过回答“是”。因此执行不完整。

我也尝试过-input = false,但是没有成功


# ---------------------------------------------------------------------------------------------------------------------
# Update the instnaces by installing newrelic agent using remote-exec
# ---------------------------------------------------------------------------------------------------------------------

resource "null_resource" "copy_file_newrelic_v_15" {

  count = "${length(aws_instance.bastion.*.ami)}"

  triggers = {
    cluster_instance_ids = "${join(",", aws_instance.bastion.*.id)}"
  }

  connection {
    host = "${element(aws_instance.bastion.*.public_ip, count.index)}"
    user = "ec2-user"
    private_key = "${file("C:/keys/nvirginia-key-pair-ajoy.pem")}"
    agent = "true"
  }

  provisioner "remote-exec" {

    connection {
        agent = "true"
        bastion_host = "${element(aws_instance.bastion.*.public_ip, count.index)}"
        bastion_user = "ec2-user"
        bastion_port = 22
        bastion_private_key = "${file("C:/keys/nvirginia-key-pair-ajoy.pem")}"
        user = "ec2-user"
        private_key = "${file("C:/keys/nvirginia-key-pair-ajoy.pem")}"
        host = "172.31.2.218"
    }

    inline = [
      "ssh ec2-user@172.31.2.218" 
    ]
  }

}

在获得“您确定要继续连接(是/否)?”的答案后,应该通过执行执行。题。手动或编程方式。

我需要向Terraform回答“是”,该问题将被Terraform接受并完成执行

 null_resource.copy_file_newrelic_v_15 (remote-exec): Connected!
null_resource.copy_file_newrelic_v_15: Still creating... (10s elapsed)
null_resource.copy_file_newrelic_v_15 (remote-exec): The authenticity of host '172.31.2.218 (172.31.2.218)' can't be established.
null_resource.copy_file_newrelic_v_15 (remote-exec): ECDSA key fingerprint is SHA256:0uaLK1VDcuHwwzCDM0GWba6RTTL4gD/hWaONHigPNyE.
null_resource.copy_file_newrelic_v_15 (remote-exec): ECDSA key fingerprint is MD5:f6:b0:39:f8:3a:dc:92:4f:c1:d9:c2:9d:13:6a:79:0a.
null_resource.copy_file_newrelic_v_15 (remote-exec): Are you sure you want to continue connecting (yes/no)?
null_resource.copy_file_newrelic_v_15: Still creating... (20s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (30s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (40s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (50s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (1m0s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (1m10s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (1m20s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (1m30s elapsed)
null_resource.copy_file_newrelic_v_15: Still creating... (1m40s elapsed)

0 个答案:

没有答案