Let's take a quick look at the steps to deploy a Java application using Spring Boot on Elastic Beanstalk (PaaS on AWS). Since this is the first post, I think there may be some areas that cannot be reached, but please understand.
You can deploy to Beanstalk from the AWS console, but this time I also want to execute it from the CI tool, so I will use CLI (EB CLI).
This time, I will explain the setting procedure of Beanstalk. I will omit the creation of the Spring Boot app. The build tool is gradle.
Mac OSX10.14.3
Install the Beanstalk CLI with homebrew.
$ brew install awsebcli
Also install the AWS CLI to save your Access Key and Secret Access Key settings.
$ brew install awscli
$ aws configure
AWS Access Key ID [None]: {Enter the access key}
AWS Secret Access Key [None]: {Enter the secret access key}
Deploy in the project directory.
Example
$ cd workspace/ebdemo/demo
First is the project settings.
$ eb init
We will set it interactively.
region
Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
5) eu-central-1 : EU (Frankfurt)
6) ap-south-1 : Asia Pacific (Mumbai)
7) ap-southeast-1 : Asia Pacific (Singapore)
8) ap-southeast-2 : Asia Pacific (Sydney)
9) ap-northeast-1 : Asia Pacific (Tokyo)
10) ap-northeast-2 : Asia Pacific (Seoul)
11) sa-east-1 : South America (Sao Paulo)
12) cn-north-1 : China (Beijing)
13) cn-northwest-1 : China (Ningxia)
14) us-east-2 : US East (Ohio)
15) ca-central-1 : Canada (Central)
16) eu-west-2 : EU (London)
17) eu-west-3 : EU (Paris)
18) eu-north-1 : EU (Stockholm)
(default is 3): 9
application
Select an application to use
1) [ Create new Application ]
(default is 1):
Enter Application Name
(default is "demo"):
Application demo has been created.
Platform → Java for Spring Boot
Select a platform.
1) Node.js
2) PHP
3) Python
4) Ruby
5) Tomcat
6) IIS
7) Docker
8) Multi-container Docker
9) GlassFish
10) Go
11) Java
12) Packer
(default is 1): 11
Select a platform version.
1) Java 8
2) Java 7
(default is 1):
SSH
Cannot setup CodeCommit because there is no Source Control setup, continuing with initialization
Do you want to set up SSH for your instances?
(Y/n): Y
Select a keypair.
1) key
2) [ Create new KeyPair ]
(default is 2): 2
Copy the application jar to the project root before deploying.
$ cp build/libs/demo-0.0.1-SNAPSHOT.jar .
Deploy.
$ eb create
Enter Environment Name
(default is demo-dev):
Enter DNS CNAME prefix
(default is demo-dev):
Select a load balancer type
1) classic
2) application
3) network
(default is 2):
It will take a few minutes.
It's working.
$ curl http://demo-dev.ap-northeast-1.elasticbeanstalk.com
Hello, World!
From the second time onward, you can deploy with just the following command. If you set SSH, access key, etc., you can automatically deploy from CI tools.
$ gradle clean build test
$ cp build/libs/demo-0.0.1-SNAPSHOT.jar .
$ eb deploy
It seems that the following settings are required in application.properties.
server.port=5000
Recommended Posts