远程执行程序无法通过aws_instance资源在Terraform中工作

时间:2019-10-24 18:48:10

标签: terraform terraform-provider-aws remote-execution

运行应用时,我在下面的代码中收到超时消息。创建了一个实例,但是remote-exec命令不起作用。 我在Windows 10计算机中运行此程序。 Terraform版本为v0.12.12 provider.aws v2.33.0

resource "aws_instance" "web" {
  ami           = "ami-54d2a63b"
  instance_type = "t2.nano"
  key_name = "terra"
  tags = {
    Name = "HelloWorld"
  }
   connection {
    type     = "ssh"
    user     = "ubuntu"
    private_key = "${file("C:/Users/Vinayak/Downloads/terra.pem")}"
    host     = self.public_ip

  }

  provisioner "remote-exec" {
    inline = [
      "echo cat > test.txt"
    ]
  }

}

1 个答案:

答案 0 :(得分:1)

请尝试将您的主机行更改为

host = "${self.public_ip}"

让人们知道您收到的实际错误消息也可能有所帮助。 :)