【问题标题】:terraform - error on creating AWS Elastic Beanstalkterraform - 创建 AWS Elastic Beanstalk 时出错
【发布时间】:2020-08-29 16:43:22
【问题描述】:

我正在尝试使用 terrafrom 配置 AWS Elastic Beanstalk。下面是我写的.tf文件:

resource "aws_s3_bucket" "default" {
  bucket = "textX"
}

resource "aws_s3_bucket_object" "default" {
  bucket = "${aws_s3_bucket.default.id}"
  key    = "test-app-version-tf--dev"
  source = "somezipFile.zip"
}

resource "aws_elastic_beanstalk_application_version" "default" {
  name        = "tf-test-version-label"
  application = "tf-test-name"
  description = "application version created by terraform"
  bucket      = "${aws_s3_bucket.default.id}"
  key         = "${aws_s3_bucket_object.default.id}"
}

resource "aws_elastic_beanstalk_application" "tftest" {
  name = "tf-test-name"
  description = "tf-test-name"
}

resource "aws_elastic_beanstalk_environment" "tfenvtest" {
    description = "test"
    application = "${aws_elastic_beanstalk_application.tftest.name}"
    name        = "synchronicity-dev"
    cname_prefix           = "ops-api-opstest"
    solution_stack_name    = "64bit Amazon Linux 2 v5.0.1 running Node.js 12"
    tier                   = "WebServer"
    wait_for_ready_timeout = "20m"        
}

根据the official documentation,我正在为aws_elastic_beanstalk_environment 模块提供所有必需的参数。

但是,在执行脚本时,我收到以下错误:

等待 Elastic Beanstalk 环境 (e-39m6ygzdxh) 时出错 准备就绪:发生 2 个错误: * 2020-05-13 12:59:02.206 +0000 UTC (e-3xff9mzdxh) :您必须为此区域中的 EC2 实例指定实例配置文件。请参阅 Managing Elastic Beanstalk Instance Profiles 了解更多信息。 * 2020-05-13 12:59:02.319 +0000 UTC (e-3xff9mzdxh) : 启动环境失败。

【问题讨论】:

  • 您使用的是哪个地区?
  • @HelderSepulveda,脚本正在使用“eu-west-1”区域。
  • 我在"us-east-1" 的错误中得到了同样的结果
  • 有根据的猜测:API 发生了一些变化,Terraform AWS 提供商还没有赶上
  • 我在使用 terraform 0.12.24 的 us-west-2 中遇到了同样的错误

标签: terraform terraform-provider-aws


【解决方案1】:

这对我有用:将下面的 setting 添加到您的 aws_elastic_beanstalk_environment 资源中:

 resource "aws_elastic_beanstalk_environment" "tfenvtest" {
 ....
 ....
    setting {
      namespace = "aws:autoscaling:launchconfiguration"
      name      = "IamInstanceProfile"
      value     = "aws-elasticbeanstalk-ec2-role"
    }
 }

更多关于常规设置的信息在这里:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html

aws_elastic_beanstalk_environment上的信息:https://www.terraform.io/docs/providers/aws/r/elastic_beanstalk_environment.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-19
    • 2015-03-05
    • 2016-04-07
    • 2016-12-29
    • 2021-02-01
    • 2020-12-04
    • 1970-01-01
    • 2018-09-20
    相关资源
    最近更新 更多