Notes and anecdotes

Techstuff rambling

Jellybeans

Create Elastic Beanstalk app with Java 8

Beanstalk is quite nice. And the awsebcli looks nice too, along with its documentation and the example guide at pypi. You can deploy straight from a local git repo in one command. You can have each branch go to a separate Beanstalk environments. So I tested it, and here are my notes:

Edit: If you want to learn this, check out the workshop we made! 

  1. If you haven’t already, install awsebcli with pip
    pip install awsebcli

    or brew

    brew install awsebcli
  2. Go to your Java App repository, or get a dummy app from here (other languages here)
    • Notice the Buildfile: This file specifies commands which are run once, and must terminate upon completion, and are ment to build your application.
    • Notice the Procfile: This is required if you have more than one jar that you wish to run. The Procfile specifies which jars should be run, and the java run commands.
  3. Connect your app to a (new) Beanstalk with the following command (cli docs for init)
    eb init 
        --region eu-central-1 
        --keyname my-ssh-key 
        --platform java-8

    Note: my-ssh-key is used to log into the created instances. It must be located in ~/.ssh/ 

  4. Connect your app to a (new) Beanstalk with one of the following command (cli docs for create)
    1. The line below specifies the app to be run on a single EC2 instance without an ELB (–single), and without databases.
      eb create <my-app-name> 
          --region eu-central-1 
          --vpc.id "vpc-cfb288a2" 
          --vpc.ec2subnets subnet-966362e2,subnet-2729dc4a 
          --instance_type t2.micro 
          --keyname my-ssh-key 
          --platform java-8 
          --single
    2. The line below specifies the app to be run on a two EC2 instances with an ELB with a specified dns, and with a database.
      eb create <my-app-name> 
          --region eu-central-1 
          --vpc.id "vpc-cfb288a2" 
          --vpc.ec2subnets subnet-966362e2,subnet-2729dc4a 
          --instance_type t2.micro 
          --keyname my-ssh-key 
          --platform java-8 
          --scale 2
          --database 
          --database.engine postgres 
          --database.user your-postgres-user 
          --database.pass your-postgres-password 
          --database.size 5
          --cname your-aws-domain-name 

Voilá! That’s it, basically. You’ve got your app up.

awsebclibeanstalkjava

tomfa • 2016-09-07


Previous Post

Next Post