在eu-west-2区域中使用Terraform时,不会自动创建Elastic Beanstalk实例配置文件

时间:2018-06-11 21:26:08

标签: amazon-web-services elastic-beanstalk terraform amazon-elastic-beanstalk aws-iam

我正在使用Terraform成功启动一些Elastic Beanstalk应用程序(单Docker配置),并在应用程序/环境创建过程中启用自动扩展。

这在我尝试过的大部分地区都运行良好,但是当我尝试在伦敦(欧洲西部2)旋转它时,我收到一个错误:

Error: Error applying plan:

1 error(s) occurred:

* aws_elastic_beanstalk_environment.my-service-env: 1 error(s) occurred:

* aws_elastic_beanstalk_environment.my-service-env: Error waiting for Elastic Beanstalk Environment (e-mt7f3i5bmq) to become ready: 2 error(s) occurred:

* 2018-06-11 19:31:29.28 +0000 UTC (e-mt7f3i5bmq) : Environment must have instance profile associated with it.
* 2018-06-11 19:31:29.39 +0000 UTC (e-mt7f3i5bmq) : Failed to launch environment.

我发现如果我手动将aws-elasticbeanstalk-ec2-role附加为IamInstanceProfile,它可以正常工作 - 但这取决于之前自动创建的角色......

是否有关于eu-west-2区域的内容,这意味着Beanstalk应用程序不会像在其他地区那样使用实例配置文件创建?

我错过了什么?

感谢您的帮助!

1 个答案:

答案 0 :(得分:4)

对于其他因这个问题而困扰的人,我找到了一个解决方案,将实例配置文件直接添加为设置。不会像通过控制台创建弹性beantalk时那样自动添加此实例概要文件。下面是定义的完整beantalk环境资源:

resource "aws_elastic_beanstalk_environment" "beanstalkenvironment" {
  name                = "dev-example"
  application         = aws_elastic_beanstalk_application.beanstalkapp.name
  solution_stack_name = "64bit Amazon Linux 2018.03 v2.14.1 running Docker 18.09.9-ce"
  version_label       = aws_elastic_beanstalk_application_version.beanstalkapplicationversion.name
  setting {
      namespace = "aws:autoscaling:launchconfiguration"
      name = "IamInstanceProfile"
      value = "aws-elasticbeanstalk-ec2-role"
  }
  setting {
    namespace = "aws:autoscaling:launchconfiguration"
    name = "InstanceType"
    value = "t2.micro"
  }
  tags = {
    Name = "test"
    Environment = "test"
  }
}

用于修复此错误的确切设置是:

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

要查找所需的值“ aws-elasticbeanstalk-ec2-role”,我检查了通过控制台创建的现有弹性beantalk实例。在环境下,在配置中有一个安全部分。所需的角色名称列为“ IAM实例配置文件”。希望这可以帮助其他在此问题上陷入困境的人。