【问题标题】:aws_launch_configuration: timeout - last error: dial tcp :22: connectex: No connection could be made because the target machine actively refused itaws_launch_configuration: timeout - last error: dial tcp :22: connectex: No connection could be made because the target machine主动拒绝它
【发布时间】:2018-12-16 08:16:19
【问题描述】:

我有以下自动缩放组的启动配置:

resource "aws_launch_configuration" "ASG-launch-config" {
  #name = "ASG-launch-config"  # see: https://github.com/hashicorp/terraform/issues/3665
  name_prefix = "ASG-launch-config-"
  image_id = "ami-a4dc46db" #Ubuntu 16.04 LTS
  #image_id = "ami-b70554c8" #Amazon Linux 2
  instance_type = "t2.micro"
  security_groups = ["${aws_security_group.WEB-DMZ.id}"]
  key_name = "MyEC2KeyPair"
  #user_data = <<-EOF
  #            #!/bin/bash
  #            echo "Hello, World" > index.html
  #            nohup busybox httpd -f -p "${var.server_port}" &
  #          EOF


  provisioner "file" {
  source="script.sh"
  destination="/tmp/script.sh"
  }
  provisioner "remote-exec" {
  inline=[
  "chmod +x /tmp/script.sh",
  "sudo /tmp/script.sh"
  ]
  }
  connection {
  user="ubuntu"
  private_key="${file("MyEC2KeyPair.pem")}"
  }

  lifecycle {
    create_before_destroy = true
  }
}

错误:应用计划时出错:

发生了 1 个错误:

  • aws_launch_configuration.ASG-launch-config: timeout - last error: dial tcp :22: connectex: 无法建立连接,因为目标计算机主动拒绝。

我想运行一个 bash 脚本来在创建的实例上安装 WordPress。 该脚本在资源类型“aws_instance”“示例”中运行良好

如何解决这个问题?

【问题讨论】:

    标签: bash amazon-web-services terraform terraform-provider-aws


    【解决方案1】:

    听起来实例拒绝了您的流量。在没有配置脚本的情况下启动一个实例,看看您是否可以使用您提供的密钥通过 SSH 连接到它。您可能希望使用 -v 向 SSH 命令添加详细日志记录。

    【讨论】:

      猜你喜欢
      • 2018-11-02
      • 2020-12-11
      • 2019-12-07
      • 2020-07-05
      • 2016-07-25
      • 1970-01-01
      • 2019-02-01
      • 2018-01-22
      • 2022-01-23
      相关资源
      最近更新 更多