无法在 VPC 中启动 Elastic beanstalk

Posted

技术标签:

【中文标题】无法在 VPC 中启动 Elastic beanstalk【英文标题】:Unable to launch Elastic beanstalk in VPC 【发布时间】:2017-01-29 23:20:33 【问题描述】:

我想将我的应用程序设置为在 VPC 中的 Elastic beanstalk 上工作,这将访问同一子网中的 rds。 这是我的 .ebextensions/conf.config 文件:

option_settings:
  aws:ec2:vpc:
    VPCId: "vpc-aaaaaaaa"
    Subnets: "subnet-zzzzzzzz"
  aws:autoscaling:launchconfiguration:
    InstanceType: m1.small
    SecurityGroups: "sg-xxxxxxxx"
    EC2KeyName: provisioner
  aws:elb:loadbalancer:
    SecurityGroups: "sg-yyyyyyyy"
  aws:elasticbeanstalk:application:environment:
    NODE_ENV: development
commands:
  01_command:
    command: "rpm -i https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-ami201503-95-9.5-2.noarch.rpm"
  02_command:
    command: "yum install postgresql95-devel -y"

我将安全组配置为允许来自所有人的流量:


    "SecurityGroups": [
        
            "IpPermissionsEgress": [
                
                    "IpProtocol": "-1", 
                    "IpRanges": [
                        
                            "CidrIp": "0.0.0.0/0"
                        
                    ], 
                    "UserIdGroupPairs": [], 
                    "PrefixListIds": []
                
            ], 
            "Description": "Security group for API server in EBS", 
            "IpPermissions": [
                
                    "PrefixListIds": [], 
                    "FromPort": 0, 
                    "IpRanges": [
                        
                            "CidrIp": "0.0.0.0/0"
                        
                    ], 
                    "ToPort": 64000, 
                    "IpProtocol": "tcp", 
                    "UserIdGroupPairs": []
                
            ], 
            "GroupName": "api_ebs_dev", 
            "VpcId": "vpc-aaaaaaaa", 
            "OwnerId": "092511111111", 
            "GroupId": "sg-xxxxxxxx"
        , 
        
            "IpPermissionsEgress": [
                
                    "IpProtocol": "-1", 
                    "IpRanges": [
                        
                            "CidrIp": "0.0.0.0/0"
                        
                    ], 
                    "UserIdGroupPairs": [], 
                    "PrefixListIds": []
                
            ], 
            "Description": "Security group for API ELB", 
            "IpPermissions": [
                
                    "PrefixListIds": [], 
                    "FromPort": 0, 
                    "IpRanges": [
                        
                            "CidrIp": "0.0.0.0/0"
                        
                    ], 
                    "ToPort": 64000, 
                    "IpProtocol": "tcp", 
                    "UserIdGroupPairs": []
                
            ], 
            "GroupName": "api_lb_dev", 
            "VpcId": "vpc-aaaaaaaa", 
            "OwnerId": "09251111111", 
            "GroupId": "sg-yyyyyyyy"
        
    ]

并看到以下错误:

2016-09-21 14:20:03    INFO    Added instance [i-d206f766] to your environment.
2016-09-21 14:30:02    WARN    Environment health has transitioned from Pending to Severe. Initialization in progress (running for 12 minutes). None of the instances are sending data. ELB health is failing or not available for all instances.
2016-09-21 14:35:43    ERROR   The EC2 instances failed to communicate with AWS Elastic Beanstalk, either because of configuration problems with the VPC or a failed EC2 instance. Check your VPC configuration and try launching the environment again.
2016-09-21 14:35:46    ERROR   Stack named 'awseb-e-5sccvbi2wa-stack' aborted operation. Current state: 'CREATE_FAILED'  Reason: The following resource(s) failed to create: [AWSEBInstanceLaunchWaitCondition]. 
2016-09-21 14:35:49    INFO    Launched environment: devtest. However, there were issues during launch. See event log for details.

同时,我可以在该 vpc 和子网中成功创建 ec2 实例,并且运行良好。

我错过了什么?

【问题讨论】:

【参考方案1】:

可能是因为rpm包:

https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-ami201503-95-9.5-2.noarch.rpm

已经不在了。如果您登录实例并检查文件:

/var/log/eb-commandprocessor.log

您可以查看自定义 .ebextensions 命令的结果。

【讨论】:

同样的事情,无需安装应用程序。设置 VPC 时无法正常创建。但我需要它才能连接到 RDS 您是否尝试从 .ebextensions/conf.config 中删除命令?实例创建将失败,因为您尝试安装的 rpm 包不存在并返回 404。 是的,我做到了。它没有改变

以上是关于无法在 VPC 中启动 Elastic beanstalk的主要内容,如果未能解决你的问题,请参考以下文章

VPC 中的 Elastic Beanstalk 应用程序无法公开访问

无法访问 Elastic Beanstalk IP 地址之一?

无法使用 Terraform 在自定义 VPC 中创建 Elastic Beanstalk 应用程序

启用 VPC 的 Lambda 函数无法在同一 VPC 中启动/访问 EC2

从 VPC 中的 Elastic Beanstalk 实例访问 RDS

VPC 中的 Elastic Beanstalk 环境变量