A Java web application with a fully automated AWS CI/CD pipeline. Source code changes trigger an automated build via AWS CodeBuild, which compiles and packages the application as a WAR file, then AWS CodeDeploy handles automated deployment to an EC2 instance running Tomcat — no manual deployment steps required.
GitHub Push
│
▼
AWS CodePipeline
│
├──► AWS CodeBuild
│ • Pulls auth token from AWS CodeArtifact
│ • Compiles Java source (Maven + Corretto 8)
│ • Packages as .WAR file
│ • Outputs: WAR + appspec.yml + deployment scripts
│
└──► AWS CodeDeploy
• Stops existing Tomcat service
• Deploys WAR to /usr/share/tomcat/webapps/
• Restarts Tomcat service
• Runs on EC2 (Linux)
| Layer | Technology |
|---|---|
| Application | Java (Corretto 8), Maven |
| Build | AWS CodeBuild |
| Artifact Storage | AWS CodeArtifact |
| Deployment | AWS CodeDeploy |
| Hosting | AWS EC2 (Linux + Tomcat) |
| Pipeline Orchestration | AWS CodePipeline |
| IaC Config | buildspec.yml, appspec.yml |
nextwork-web-project/
├── src/main/webapp/ # Java web application source
├── scripts/
│ ├── install_dependencies.sh # CodeDeploy: BeforeInstall hook
│ ├── start_server.sh # CodeDeploy: ApplicationStart hook
│ └── stop_server.sh # CodeDeploy: ApplicationStop hook
├── buildspec.yml # AWS CodeBuild build instructions
├── appspec.yml # AWS CodeDeploy deployment specification
├── pom.xml # Maven project configuration
└── settings.xml # Maven settings (CodeArtifact repo config)
Defines the three-phase CodeBuild process:
- Install: Sets Java runtime to Corretto 8
- Pre-build: Authenticates with AWS CodeArtifact to pull private dependencies
- Build: Compiles with
mvn compile, then packages withmvn package - Artifacts: Exports the WAR file, appspec.yml, and deployment scripts for CodeDeploy
Tells CodeDeploy exactly how to deploy the artifact:
- Copies the WAR to Tomcat's webapps directory
- Runs lifecycle hooks: stop server → install dependencies → start server
Shell scripts executed by CodeDeploy during deployment lifecycle hooks — handles Tomcat service management and dependency installation on the EC2 instance.
- AWS CodePipeline: End-to-end pipeline orchestration from source to production
- AWS CodeBuild: Managed build environment — no build servers to maintain
- AWS CodeArtifact: Private Maven repository with token-based authentication
- AWS CodeDeploy: Automated, scripted deployment with lifecycle hooks
- EC2 + Tomcat: Java web app hosting with controlled start/stop deployment process
- Deployment Lifecycle Hooks: BeforeInstall → ApplicationStart → ApplicationStop
- AWS account with CodePipeline, CodeBuild, CodeDeploy, and CodeArtifact configured
- EC2 instance with CodeDeploy agent installed and Tomcat running
- IAM roles with appropriate permissions for each service
- CodeArtifact domain named
nextworkset up inus-east-1
- Blue/green deployment strategy via CodeDeploy to achieve zero-downtime releases
- Automated rollback trigger on deployment failure
- CloudWatch alarms and SNS notifications on build/deploy failures
- Terraform to provision the EC2 instance, IAM roles, and pipeline infrastructure as code