首页 > 解决方案 > AWS Elastic Beanstalk 启动到默认 VPC

问题描述

我正在尝试在我的 VPC 中启动 Tomcat Beanstalk 实例。但由于某种原因,实例不考虑我的配置模板。

我做了什么 :

  1. 在单独的脚本中创建 VPC 并手动启动请求的实例并通过 SSH 连接到它

问题 1:如果我出于某种原因使用 cloud-formation,则脚本(如下)会为 Beanstalk 创建一个新堆栈

问题 2:成功启动后,beantalk 会创建到默认 VPC 中,如果我删除默认 VPC,则会崩溃。

我该如何调试呢?为什么会发生这种情况,因为我将正确的参数传递给脚本?

  SampleApplication:
    Type: 'AWS::ElasticBeanstalk::Application'
    Properties:
      ApplicationName: !Ref ApplicationName
      Description: OCAP's AWS Elastic Beanstalk Sample Application

  SampleApplicationVersion:
    Type: 'AWS::ElasticBeanstalk::ApplicationVersion'
    Properties:
      Description: Version 1.0
      ApplicationName: !Ref SampleApplication
      SourceBundle:
        S3Bucket: !Ref AppS3Bucket
        S3Key: !Ref AppS3Key

  SampleIdentityEnvironment:
    Type: 'AWS::ElasticBeanstalk::Environment'
    Properties:
      ApplicationName: !Ref SampleApplication
      EnvironmentName : OCAPSampleIdentityManager
      VersionLabel: !Ref SampleApplicationVersion
      SolutionStackName: !FindInMap [ StackMap, !Ref StackType, stackName ]
    DependsOn:
      - ConfigurationTemplate
      - SampleApplicationVersion

配置模板:

Type: AWS::ElasticBeanstalk::ConfigurationTemplate
Properties:
  ApplicationName: !Ref SampleApplication
  Description: 64bit Amazon Linux running Tomcat 7
  SolutionStackName: !FindInMap [ StackMap, !Ref StackType, stackName ]
  OptionSettings:

    - Namespace: aws:autoscaling:launchconfiguration
      OptionName: EC2KeyName
      Value: !Ref KeyName

    - Namespace: aws:ec2:vpc
      OptionName: VPCId
      Value : vpc-0123456789

    - Namespace: 'aws:ec2:vpc'
      OptionName: Subnets
      Value: subnet-0123456789, subnet-0123456789

    - Namespace: 'aws:ec2:vpc'
      OptionName: ELBSubnets
      Value: subnet-0123456789, subnet-0123456789

    - Namespace: 'aws:ec2:vpc'
      OptionName: AssociatePublicIpAddress
      Value: 'true'

标签: amazon-web-servicesamazon-elastic-beanstalk

解决方案


已解决的问题 2:您需要在“SampleIdentityEnvironment:”中定义它

TemplateName: !Ref ConfigurationTemplate

推荐阅读