【问题标题】:Terraform Error launching source instance: timeout while waiting for state to become 'success' (timeout: 15s)Terraform 启动源实例时出错:等待状态变为“成功”时超时(超时:15 秒)
【发布时间】:2017-08-04 04:01:05
【问题描述】:

我为 AWS 配置了 terraform。我已经自动化了 2 个 EC2 实例和 2 个 ECS 优化实例。

当我申请 terraform 时,所有 4 个实例都会收到 **Error launching source instance: timeout while waiting for the state to become 'success' (timeout: 15s)**

我在一些博客上发现这可能是因为 AMI 不一致或 AMI id 拼写错误。

因此,我已修复了我的 AMI id 中的错字并能够启动 2 个实例。但是,我仍然收到其他两个实例的超时错误。

我使用的是 terraform 版本:0.9.6 我创建 ec2 的 TF 代码:

resource "aws_instance" "node1" {
  # ECS-optimized AMI for us-west-2
        ami = "ami-62d35c02"
        instance_type = "t2.medium"
    availability_zone = "us-west-2a"
    security_groups = [
        "${aws_security_group.sg.name}"
    ]
    key_name        = "key"
                tags {
            Name           = "Node Server 1"
        }
        user_data = <<EOF
        #!/bin/bash
        echo ECS_CLUSTER=uat >> /etc/ecs/ecs.config
        EOF
        iam_instance_profile = "${aws_iam_instance_profile.ecs.name}"
}

resource "aws_instance" "node2" {
  # ECS-optimized AMI for us-west-2
        ami = "ami-62d35c02"
        instance_type = "t2.medium"
        availability_zone = "us-west-2b"
        security_groups = [
                "${aws_security_group.sg.name}"
        ]
        key_name        = "key"
                tags {
                Name           = "Node Server 2"
        }
        user_data = <<EOF
                #!/bin/bash
                echo ECS_CLUSTER=uat >> /etc/ecs/ecs.config
                EOF
                iam_instance_profile = "${aws_iam_instance_profile.ecs.name}"
}

resource "aws_instance" "mongo" {
        ami = "ami-63ad4b1b"
        instance_type = "t2.medium"
        availability_zone = "us-west-2c"
        security_groups = [
                "${aws_security_group.sg.name}"
        ]
        key_name        = "key"
                tags {
                Name           = "MongoDB Server"
        }
}

resource "aws_instance" "mysql" {
        ami = "ami-22ac4a5a"
        instance_type = "t2.medium"
        availability_zone = "us-west-2c"
        security_groups = [
                "${aws_security_group.sg.name}"
        ]
        key_name        = "key"
                tags {
                Name           = "MySQL Server"
        }
}

谁能帮帮我。

提前致谢。

【问题讨论】:

  • 请出示您的实际地形代码
  • @RaGe 我已经更新了问题中的代码。请看一下。我在错误发生前几次更改了 AMI id。这会是个问题吗?

标签: amazon-web-services amazon-ec2 amazon terraform


【解决方案1】:

可以使用 Terraform 调试日志 确定潜在问题。当我遇到此错误时,就我而言,问题是 AWS 没有足够的容量来满足我在我配置的可用区中选择的实例类型。

调试此错误的好方法如下:

  1. 设置 TF_LOG 环境变量以启用 Terraform 调试日志。这可以在 Linux 或 Mac 上使用以下命令完成:
export TF_LOG=DEBUG
  1. 运行terraform apply 命令。
  2. 当出现应用更改的提示时,写上yes,如果计划适合您,请点击Enter
  3. 如果您收到错误,请搜索其上方几行的[DEBUG] 条目以确定潜在问题。举个例子,就我而言,我发现了以下内容:
[DEBUG] plugin.terraform-provider-aws_v1.58.0_x4:
<Response>
  <Errors>
    <Error>
      <Code>InsufficientInstanceCapacity</Code>
      <Message>We currently do not have sufficient t3.medium capacity in the Availability Zone you requested (us-west-1a). Our system will be working on provisioning additional capacity. You can currently get t3.medium capacity by not specifying an
        Availability Zone in your request or choosing us-west-1b.</Message>
    </Error>
  </Errors>
  <RequestID>...</RequestID>
</Response>
  1. 这应该允许您在要部署的基础架构中执行纠正措施。

【讨论】:

    猜你喜欢
    • 2020-11-17
    • 2020-12-13
    • 2020-10-30
    • 2018-05-10
    • 2020-11-27
    • 1970-01-01
    • 2015-01-18
    • 2020-12-17
    • 2021-10-16
    相关资源
    最近更新 更多