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.
Finally the final stage. Create a CodePipeline and deploy it to your Elastic Beanstalk environment.
(1) Find CodePipeline on the management console and click it.
(2) Click "Create Pipeline".
(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.
(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) |
(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).
(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
(6) When you return to the "Add build stage" screen, check that "
(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" |
(8) After transitioning to the "Review" screen, check the contents and click "Create Pipeline".
(9) The pipeline is created, and the commit-pushed code is built and deployed in order in "2. Creating a Git repository".
(10) If the deployment is successful (green check mark is attached), it is OK.
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".
(12) Click "Environment" in the navigation pane.
(13) If the health is "OK" as shown below, you are successful! (1)
(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
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".
(2) Click "Environment" in the navigation pane.
(3) Select the radio button of the target environment (1) and click "Action"> "Exit Environment".
(4) The screen will change to the "Confirm Delete Environment" screen. Enter the name of the environment (①) and click "Delete" (②).
(5) Next, delete the "application". Click "Applications" in the Elastic Beanstalk navigation pane.
(6) Select the radio button of the target application (1) and click "Action"> "Delete Application".
(7) The modal of "Confirm application deletion" will be launched. Enter the target application name (①) and click "Delete" (②).
[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".
(2) Select the radio button of the target pipeline (1) and click "Delete Pipeline" (2).
(3) A modal for confirming deletion will be launched. Enter "delete" (①) and click "Delete" (②).
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.
-Tutorial: Create a simple pipeline (CodeCommit repository) | aws
-AWS Elastic Beanstalk Fees | aws -AWS CodePipeline Fees | aws
Recommended Posts