[Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 3

Hands-on to CI / CD Java application (gets value from database and returns result in JSON format) to Elastic Beanstalk with CodePipeline. [Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 2 It is a continuation of.

environment

procedure

5. Creating a pipeline

Finally the final stage. Create a CodePipeline and deploy it to your Elastic Beanstalk environment.

[1] Creating CodePipeline

(1) Find CodePipeline on the management console and click it. image.png

(2) Click "Create Pipeline". image.png

(3) After transitioning to the "Select pipeline settings" screen, enter the "Pipeline name" (①), select "New service role" (②: Default), and click "Next" (Next) ③). This will create the role described in "Role Name" when you create the pipeline. image.png

(4) Next is the "Add Source Stage" screen. Enter and select as follows and click "Next" (⑤)

No name Settings
Source provider AWS CodeCommit
Repository name 手順2:Gitリポジトリの作成で作成したRepository name
Branch name master
Change detection options Amazon CloudWatch Events (recommended)

image.png

(5) Next is the "Add Build Stage" screen. In "Build a Provider", select "AWS CodeBuild" (1), select "Asia Pacific (Tokyo)" for "Region" (2), and click "Create Project" (3). image.png

(6) The "Create Build" window will appear. Enter and set as follows, and click "Proceed to Code Pipeline".

No name Settings
Project name Arbitrary name (this time "sample"-eb-java-build」)
Environmental image Managed image
operating system AmazonLinux 2
runtime Standard
image aws/codebuild/amazonlinux2-x86_64-standard:3.0
Image version Select the latest one
Environment type Linux
Service role 新しいService role
Role name Automatically entered (change if necessary)
Build specifications Insert build command
Build command * Enter as
Input mode Editor (Capture is in edit mode with editor by clicking "Switch to editor")

* Contents of build command


version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto8
  build:
    commands:
       - ./gradlew test

image.png

(6) When you return to the "Add build stage" screen, check that " was created successfully by CodeBuild" (1) and click "Next" (1). ②). image.png

(7) After transitioning to the "Deploy-Optional" screen, enter and select as follows, and click "Next" (⑤).

No name Settings
Deployment provider AWS Elastic Beanstalk
region Asia Pacific (②)
Application name 「3.Application created in "Creating an Elastic Beanstalk Environment"
Environment name 「3.Environment created in "Creating an Elastic Beanstalk environment"

image.png

(8) After transitioning to the "Review" screen, check the contents and click "Create Pipeline". image.png

(9) The pipeline is created, and the commit-pushed code is built and deployed in order in "2. Creating a Git repository". image.png

(10) If the deployment is successful (green check mark is attached), it is OK. image.png

From now on, this pipeline will run every time a change is made to the master branch of the CodeCommit repository. In a real environment, it will be executed when pull request → merged from a child branch.

If you get an error when running the pipeline [CodePipeline x Elastic Beanstalk] CI / CD of Java application to Elastic Beanstalk with CodePipeline, error and countermeasure summary Please try to solve it by referring to.

(11) Let's also check Elastic Beanstalk. In the management console, click "Services" (1)> "Elastic Beanstalk". image.png

(12) Click "Environment" in the navigation pane. image.png

(13) If the health is "OK" as shown below, you are successful! (1) image.png

[2] Operation check

(1) Let's check the operation. In the browser, enter and enter as follows, and if the following result is returned, it is successful!

Execution URL


(2)Domain described in ②/shop-information/1

image.png

6. Clean up

Finally, we will clean up. If you leave it as it is, you will be charged only for the operating amount of EC2 instance and RDS instance created by creating Elastic Beanstalk environment, so let's clean up (delete) it.

[1]Elastic Beanstalk (1) On the management console, click "Services" (1)> "Elastic Beanstalk". image.png

(2) Click "Environment" in the navigation pane. image.png

(3) Select the radio button of the target environment (1) and click "Action"> "Exit Environment". image.png

(4) The screen will change to the "Confirm Delete Environment" screen. Enter the name of the environment (①) and click "Delete" (②). image.png

(5) Next, delete the "application". Click "Applications" in the Elastic Beanstalk navigation pane. image.png

(6) Select the radio button of the target application (1) and click "Action"> "Delete Application". image.png

(7) The modal of "Confirm application deletion" will be launched. Enter the target application name (①) and click "Delete" (②). image.png

[2]CodePipeline (1) Next, Code Pipeline. At least, if you don't change the chord, you won't be charged, but conversely, if you make any changes to the chord, you will be charged, so delete this as well.

On the management console, click "Services" (1)> "Code Pipeline". image.png

(2) Select the radio button of the target pipeline (1) and click "Delete Pipeline" (2). image.png

(3) A modal for confirming deletion will be launched. Enter "delete" (①) and click "Delete" (②). image.png

At the end

Thank you for your hard work for a long time.

I'm going to break my heart many times by changing the authority of gradlew in 1- [3]-(5) for 3 days, and in the deployment stage of 5- [1]-(10) with 3 errors. became. However, there is no sense of accomplishment when it is completed! !! I have compiled this article in the hope that it will be useful to as many people as possible.

I would appreciate it if you could comment on any points that you did not reach or noticed.

reference

5. Creating a pipeline

-Tutorial: Create a simple pipeline (CodeCommit repository) | aws

6. Clean up

-AWS Elastic Beanstalk Fees | aws -AWS CodePipeline Fees | aws

Recommended Posts

[Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 2
[Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 3
[Code Pipeline x Elastic Beanstalk] Summary of errors and countermeasures for CI / CD Java applications to Elastic Beanstalk with Code Pipeline
[Code Pipeline x Elastic Beanstalk] Update the runtime version from Java 8 to Corretto 11 on the Java SE platform
Java to learn with ramen [Part 1]
CI / CD Spring application with CircleCI (Heroku)
Minimum configuration sample to automatically release Lambda by Java with Code pipeline
Introduction to Java development environment & Spring Boot application created with VS Code
[Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 2
[Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 1
[Code Pipeline x Elastic Beanstalk] CI / CD Java application to Elastic Beanstalk with Code Pipeline Part 3
Rip a CD to MP3 with Ubuntu 18.04 LTS
[Java] How to start a new line with StringBuilder
A memo to start Java programming with VS Code (2020-04 version)
[Circle CI] A story I was addicted to at Start Building
[Code Pipeline x Elastic Beanstalk] Summary of errors and countermeasures for CI / CD Java applications to Elastic Beanstalk with Code Pipeline
How to build Java development environment with VS Code
I tried to modernize a Java EE application with OpenShift.
Java web application development environment construction with VS Code (struts2)
Sample code to parse date and time with Java SimpleDateFormat
A memo to start Java programming with VS Code (2020-04 version)
AWS Elastic Beanstalk # 1 with Java starting from scratch-Building a Java web application environment using the EB CLI-
Java to play with Function
Connect to DB with Java
Connect to MySQL 8 with Java
Settings to delete unused Java imports when saving with VS Code
Connecting to a database with Java (Part 1) Maybe the basic method
I tried to make an Android application with MVC now (Java)
Introduction to Java that can be understood even with Krillin (Part 1)