MF06-PRA06-MarcFernandez-AWSDeployment #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MF06-PRA06: AWS Deployment for Spring Boot Docker Application
CIFO La Violeta - DevOps IFCT0116-24 MF06
This practical exercise will guide you through setting up an AWS environment to deploy a Spring Boot Docker application created in MF05-PRA05, using AWS ECR, ECS, and Fargate.
Tasks
1. Create an AWS Account
2. Set Up AWS Budget and Billing Alerts
Having problems during the budget creation:

Solved by creating a role who has full access to AWS Budget Actions:

The budget has been created successfully:

3. Create AWS Services for Spring Boot Docker Deployment
Set up Amazon Elastic Container Registry (ECR)
Configure Amazon Elastic Container Service (ECS)
Set up AWS Fargate
New task definition:

Container creation:

Service creation:
Enviroment

Deployment

Networking

Load Balancing


4. Update Jenkins Pipeline for AWS Deployment
Modified Jenkins pipeline to include AWS deployment steps:
pipeline { agent any environment { AWS_ACCOUNT_ID="954976290202" AWS_DEFAULT_REGION="eu-central-1" IMAGE_REPO_NAME="books/booksback" IMAGE_TAG="${env.BUILD_ID}" REPOSITORY_URI = "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_REPO_NAME}" IMAGE_NAME = 'books/booksback' } tools { maven 'M3' jdk 'JDK21' } stages { stage('Checkout') { steps { git 'https://github.com/AlbertProfe/BooksPageable.git' } } stage('Build') { steps { sh 'mvn clean package' } } stage('Archive') { steps { archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true } } stage('Build Docker Image') { steps { script { // Build the Docker image and tag it with both BUILD_NUMBER and latest sh "docker build -t ${IMAGE_NAME}:${IMAGE_TAG} -t ${IMAGE_NAME}:latest ." } } } stage('Push to ECR') { steps { script { sh "aws ecr-public get-login-password --region eu-central-1 | docker login --username AWS --password-stdin public.ecr.aws/c3d9t1n8" sh "docker tag ${IMAGE_REPO_NAME}:${IMAGE_TAG} ${REPOSITORY_URI}:${IMAGE_TAG}" sh "docker push ${REPOSITORY_URI}:${IMAGE_TAG}" } } } stage('Deploy to ECS') { steps { script { sh "aws ecs update-service --cluster booksback --booksbackSpringService --force-new-deployment" } } } } post { always { // Logout from DockerHub and remove images sh "docker logout" sh "docker rmi ${IMAGE_NAME}:${IMAGE_TAG} || true" sh "docker rmi ${IMAGE_NAME}:latest || true" } } }5. Deploy Spring Boot Application
1.Access key creation:

2.Errors and Changes
Error 1:

Change:

Error 2:

Change:

Error 3:

Changes:

Error 4:

Change:

I could not find a solution yet.