Home > Blockchain >  Creating Elastic Beanstalk environment with new application with Java Sample Application using AWS C
Creating Elastic Beanstalk environment with new application with Java Sample Application using AWS C

Time:08-19

I'm a bit stuck with this one. I managed to create an elastic beanstalk environment with my own Cloud Formation template, but I can only launch it for an existing application. How can I use the same resource (AWS::ElasticBeanstalk::Environment) to also create a new application and how do I deploy the standard AWS Java Sample Application to this new environment using the same template.

If I use this:

Resources:
  MyEB:
    Type: AWS::ElasticBeanstalk::Environment
    Properties:
      ApplicationName: customerApp

there will be an error saying that customerApp does not exist.

As per Marcin's request, my full template with values removed to make it shorter if that makes sense:

Resources:
  MyEB:
    Type: AWS::ElasticBeanstalk::Environment
    Properties:
      ApplicationName: customerApp
      Description: Test
      PlatformArn: arn:aws:elasticbeanstalk:eu-west-1::platform/Tomcat 8.5 with Corretto 8 running on 64bit Amazon Linux 2/4.2.17
      EnvironmentName: iw-test3
      OptionSettings:
        - Namespace: aws:autoscaling:launchconfiguration
          OptionName: ImageId

        - Namespace: aws:autoscaling:launchconfiguration
          OptionName: DisableIMDSv1

        - Namespace: aws:elasticbeanstalk:application:environment
          OptionName: username

        - Namespace: aws:elasticbeanstalk:application:environment
          OptionName: password

        - Namespace: aws:elasticbeanstalk:application:environment
          OptionName: rest_client_id

        - Namespace: aws:elasticbeanstalk:application:environment
          OptionName: rest_client_secret

        - Namespace: aws:ec2:vpc
          OptionName: VPCId      

        - Namespace: aws:ec2:vpc
          OptionName: Subnets

        - Namespace: aws:ec2:vpc
          OptionName: ELBSubnets

        - Namespace: aws:elbv2:loadbalancer
          OptionName: SharedLoadBalancer 
        
        - Namespace: aws:elbv2:listener:443
          OptionName: Rules   

        - Namespace: aws:elasticbeanstalk:environment:process:default
          OptionName: HealthCheckPath
          Value: /health

        - Namespace: aws:elasticbeanstalk:managedactions
          OptionName: ManagedActionsEnabled
          Value: true

        - Namespace: aws:elasticbeanstalk:managedactions
          OptionName: PreferredStartTime

        - Namespace: aws:elasticbeanstalk:managedactions:platformupdate
          OptionName: UpdateLevel

        - Namespace: aws:ec2:instances
          OptionName: InstanceTypes
    
        - Namespace: aws:ec2:instances
          OptionName: SupportedArchitectures

        - Namespace: aws:autoscaling:asg
          OptionName: MaxSize

        - Namespace: aws:elasticbeanstalk:environment:proxy
          OptionName: ProxyServer

        - Namespace: aws:elasticbeanstalk:environment
          OptionName: ServiceRole

        - Namespace: aws:elasticbeanstalk:environment
          OptionName: LoadBalancerIsShared

        - Namespace: aws:elasticbeanstalk:environment
          OptionName: LoadBalancerType

        - Namespace: aws:ec2:vpc
          OptionName: AssociatePublicIpAddress

        - Namespace: aws:autoscaling:launchconfiguration
          OptionName: IamInstanceProfile     

        - Namespace: aws:elbv2:listenerrule:dnsRule
          OptionName: PathPatterns
       
        - Namespace: aws:elbv2:listenerrule:dnsRule
          OptionName: Priority        

        - Namespace: aws:elbv2:listenerrule:dnsRule
          OptionName: Process
      
        - Namespace: aws:elbv2:listenerrule:dnsRule
          OptionName: HostHeaders
         

update

I added the below resources:

MyApplication:
    Type: AWS::ElasticBeanstalk::Application
    Properties:
      Description: Test Application 
  MyApplicationVarsion:
    Type: AWS::ElasticBeanstalk::ApplicationVersion
    Properties:
      ApplicationName: customerApp_IW
      Description: Test Application Version
      SourceBundle: 
        S3Bucket: !Sub "elasticbeanstalk-samples-${AWS::Region}"
        S3Key: corretto.zip

And the error am getting now is this:

Unable to download from S3 location (Bucket: elasticbeanstalk-samples-eu-west-1 Key: corretto.zip). Reason: Forbidden: S3Bucket=elasticbeanstalk-samples-eu-west-1, S3Key=corretto.zip (Service: AWSElasticBeanstalk; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 8abc30ac-fd88-4828-95bd-67e3ed69aebe; Proxy: null)

CodePudding user response:

You have to define your own AWS::ElasticBeanstalk::ApplicationVersion. Then you define VersionLabel to deploy your specific zip.

  • Related