I'm having a problem with my .war file deployment through CodePipeline (using CodeBuild) to my Elastic Beanstalk environment. After a successful pipeline deployment, it throws a 404 error (see picture).
However, when I upload the .war file from my project code directly into my Elastic Beanstalk environment, it works just fine.
Ideally, I want to just be able to run the CodePipeline to update the versioning.
My CodeBuild (buildspec) -
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- ls -la
- cd prod/
- mvn clean
- mvn install
# post_build:
# commands:
artifacts:
files:
- backend/target/backend-0.0.1-SNAPSHOT.war
# name: artifact
base-directory: prod/
404 Error -
I've tried this as well and it still gives me a 404 error
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- ls -la
- cd prod/
- mvn clean
- mvn install
post_build:
commands:
- mv backend/target/backend-0.0.1-SNAPSHOT.war ROOT.war
artifacts:
files:
- ROOT.war
AWS Elastic Beanstalk expects to find and run a ROOT.war
at root directory.
ROOT.war runs at myapp.elasticbeanstalk.com. In a single WAR source bundle, the application always runs at the root path. (Source)
You have two options to resolve this
backend/target/backend-0.0.1-SNAPSHOT.war
)Option 2 approach:
post_build:
commands:
- mv backend/target/backend-0.0.1-SNAPSHOT.war ROOT.war