Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Deploy to AWS

Philippa Hack edited this page May 16, 2019 · 1 revision

Push Docker image to Amazon ECR

Use the AWS CLI to request temporary credentials for your private AWS Docker repository. get-login returns a command containing a temporary password, which can be executed in the shell like so: (The region value may vary.)

$(aws ecr get-login --no-include-email --region us-east-2)

Build the docker image, and tag the image with the fully qualified repository name.

docker tag IMAGE_ID XXXXXXXXXXXX.dkr.ecr.us-east-2.amazonaws.com/REPOSITORY_NAME

docker push XXXXXXXXXXXX.dkr.ecr.us-east-2.amazonaws.com/REPOSITORY_NAME

AWS Configuration in the Console

Unless otherwise specified here, use the defaults.

Create a task definition for the image. In the configuration wizard, add the container from before, and to it add a port mapping for 8080, as this is what the Spring Boot app currently expects TCP traffic to arrive on.

Create a Cluster: EC2 Linux + Networking, t2.micro. In the configuration wizard, add an inbound security rule allowing traffic on port 8080.

Create a Service, with the task definition with this container.

What is optional, but useful, is to specify a key pair for SSH'ing to the instances. In the AWS console, generate a key pair, and download the .pem file. In the security group of your instance, add an inbound security rule allowing port 22, ideally for only your IP range. Specify the .pem file like so:

ssh -i /path/my-key-pair.pem [email protected]

Blog post on Spring Boot + AWS