[JAVA] CodeStar Banzai! CI / CD pipeline to start with just a few clicks

I tried to build a CI / CD pipeline using CodeStar, so I will introduce it.

What is CodeStar?

It seems to be a service that quickly builds a CI / CD pipeline + execution environment using AWS managed services CodePipeline, CodeCommit, CodeBuild, and CodeDeploy.

https://aws.amazon.com/jp/codestar/

Alright, let's move it! !!

1. Project creation

Select Code Star from the management console and click "start a project". Then, the screen for selecting the project template is displayed.

The categories are from Web application, Web service, Alexa Skill, Static Website, Languages are from Ruby, Node.js, Java, Python, PHP, HTML 5 The execution environment can be selected from Beanstalk, EC2, and Lambda.

You can also choose Web Application x Node.js x Lambda, which is like the current era.

Well, I want to use CodeBuild here, so select "Web Application x Java Spring x EC2".

使う1.png

Then enter the project name. Set the instance type. Click, click.

使う2.png

。。。 Well, this is the end of the work of building the CI / CD pipeline.

And wait 10 minutes. CodePipeline, CodeCommit, CodeBuild, CodeDeploy, and the dashboard to check this in an integrated manner have been made nice. Of course, the java web application is also running.

Dashboard

使う4修正.png

CodePipeline 使う8.png

CodeCommit 使う5.png

CodeBuild 使う6.png

CodeDeploy 使う7.png

Deployed java web application

12.png

2.CI/CDパイプライン実行

From here is the production. Check the connection information to git with IAM (user ⇒ authentication information ⇒ HTTPS Git authentication information "generate" of AWS CodeCommit), and clone the source code on code commit. Then something like this will fall.

tree


.
├── README.md
├── appspec.yml
├── buildspec.yml
├── pom.xml
├── scripts
│   ├── install_dependencies
│   └── start_server
└── src
    └── main
        ├── java
        │   └── com
        │       └── aws
        │           └── codestar
        │               └── projecttemplates
        │                   ├── HelloWorldAppInitializer.java
        │                   ├── configuration
        │                   │   ├── ApplicationConfig.java
        │                   │   └── MvcConfig.java
        │                   └── controller
        │                       └── HelloWorldController.java
        ├── resources
        │   └── application.properties
        └── webapp
            ├── WEB-INF
            │   └── views
            │       └── index.jsp
            └── resources
                ├── gradients.css
                ├── set-background.js
                ├── styles.css
                └── tweet.svg

Hmmm, I see. Here, I modified index.jsp a little to check the CI / CD pipeline quickly. Then push to code commit. You can also check the changed contents on code commit.

使う11.png Then. .. ..

使う9.png

The pipeline has started to move Apparently, the movement seems to be doing something like this.

--Source: When a new code is pushed, the source code is acquired from code commit and stored in S3. --Build: Get the source code from S3 and build. And store the built module in S3. --Application: Deploy the module stored in S3 to EC2.

5 minutes to wait. Successful deployment. And when I check the previous screen. .. ..

使う10.png

It's changed! Easy! !!

If you use this

--You can build a CI / CD pipeline using major languages such as Java and Ruby at explosive speed. --Free from Jenkins.

But. ..

--I haven't come to the Tokyo region yet. --It's a problem on the CodeStar or code commit side, but you can't use pull request. ..

It seems that it is still difficult to use it as an application development environment / execution environment for production, but This may be enough for poc.

Recommended Posts

CodeStar Banzai! CI / CD pipeline to start with just a few clicks
[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