[Java] [CodePipeline x Elastic Beanstalk] Error of CI/CD of Java application to Elastic Beanstalk with CodePipeline and its corresponding method summary

2 minute read

CI/CD Java Application to Elastic Beanstalk with CodePipeline The following is a summary of the errors that can occur and their corresponding methods.

Environment

  • OS: Windows10
  • IDE: Eclipse 2020-03
  • JDK: Amazon Correto 8
  • Framework: Spring Boot
  • AWS -CodePipeline -CodeCommit -CodeBuild -CodeDeploy -Elastic Beantalk -Java SE (Java 8 version 2.10.8)
    → *This is not the latest version released on June 3, 2020. Please understand. -RDS: MySQL Community Edition (Version 8.0.17)

Error and countermeasures

1. Elastic Beanstalk

(1) 502 (Bad Gateway) error occurs when accessing

Let’s check the settings again. [CodePipeline x Elastic Beanstalk] CI/CD of Java application to Elastic Beanstalk with CodePipeline Part 2 Review “[2] Additional settings” in “3. Creating an Elastic Beanstalk environment” and check whether there are any omissions in the settings.

2. RDS

(1) Cannot access the database

Let’s check the permission settings once again. [CodePipeline x Elastic Beanstalk] CI/CD of Java application to Elastic Beanstalk with CodePipeline Part 2 Review (4) to (9) of “[1] Connection settings in RDS” of “4. Database settings” of and check if there is any leak.

3. CodePipeline

(1) ``The action failed because either the artifact or the Amazon S3 bucket could not be found.

image.png

It can be resolved by changing the input artifact from Build Artifact to Source Artifact. Follow the procedure below to change it.

① Click “Edit” in the pipeline. image.png

② In the “Deploy” field, click “Edit Stage”. image.png

③ Click the edit mark (?). image.png

④ Change “Input Artifact” to “Source Artifact” (1) and click “Finish” (2). image.png

⑤ Click “Save”. image.png

⑥ Click “Save”. image.png

(2) “Deployment failed. The provided role does not have sufficient permissions: Failed to deploy application. Service: AWS Logs…”

This error occurs because you do not have access to CloudWatchLogs. This can be resolved by granting the “CloudWatchLogsFullAccess” policy to the role created for CodePipeline.

Below are the steps.

(1) On the management console, search for “IAM” and click it. image.png

② “Role” (①)> Search for the target CodePipeline role (②) and click the role name (③). image.png

③ Click “Attach policy” image.png

④ Search for “CloudWatchLogsFullAccess” (1), check it (2), and click “Attach Policy” (3). image.png

At the end

As I wrote in the main part, I got an error 3 times at the stage of 1-[3]-(5) change of gradlew of the main part, and 5-(1)-(10) deployment stage. I stumbled around, and I felt like I was breaking my heart. Even if an error occurs, don’t be shy, rather feel like how to solve it and enjoy it!