To ssh into AWS ec2 instances the default user id is usually ‘ec2-user’ (see my ec2 ssh checklist here).
Lightsail vps instances appear to use different default userids, depending on the OS. For example, for an Ubuntu Lightsail instance the default ssh userid is ‘ubuntu’:
The EB cli provides an ‘eb ssh env-name’ command to provide ssh access into a running EC2 instance. If the environment wasn’t setup to enable ssh, you’ll see this:
> eb ssh test ERROR: This environment is not set up for SSH. Use "eb ssh --setup" to set up SSH for the environment.
After running ‘eb ssh –setup’ you’ll be prompted to confirm the environment name, and then select a previously configured SSH keypair to use to provide auth when logging on to the instance.
If an EC2 instance is already running in the env, this setup step configures new EC2 instances to enable ssh, and then conducts a rolling update to take down any previously started EC2 instances and replace them with new instances.
In my previous post, I looked at using the EB cli to deploy a Spring Boot app to Beanstalk. If you have an app that you have packaged in a Docker container, you can prepare this for deployment to Beanstalk using the EB cli command:
Next create a Beanstalk environment for deploying your app:
$ eb create environment-name
This will take a few minutes on your first deploy as it provisions everything required for running your app on Beanstalk, including an Auto Scaling Group and an EC2 instance.
Deploying a Spring Boot app to AWS Elastic Beanstalk is relatively easy using the eb cli tool, if you’re prepared to accept some defaults as part of the deploy. It’s probably possible to configure/customize IAM roles, Security Groups etc, but accepting the defaults is an easy way to deploy during development.
To initialize a new Elastic Beanstalk deployment, run in the root of your Spring Boot source folder:
eb init
Before creating the environment and deploying your app, edit the .elasticbeanstalk/config.yml that the previous step creates, to configure the built app jar to be deployed, by adding this section:
To create a single dev/test env with no load balancing:
eb create --single
To tear down the deployed ec2 instance running your Spring Boot app:
eb terminate
Service Port Configuration
By default, Beanstalk services are deployed on port 5000. Since Spring Boot apps are on port 8080 by default, the quickest way to configure Spring Boot to accept incoming requests on port 5000 is to edit the ‘Updates, monitoring and logging’ section and add a new env var for Spring Boot to reconfigure to use port 5000 instead (this is described here)