Create ECS Service
- Also in the Task interface just created, we will create an ECS service to run the newly created Task definition.
- Select Deploy
- Select Create Service

- Setup environment
- Select cluster (Cluster-STACK_NAME)

- Configure Deployment
- Application type, default Service
- Name the Service name
- Desired tasks, select 1

- Configure Network
- VPC, select Mysfits-STACK_NAME
- Subnets, select private subnets
- For Security group, select Use an existing security group
- Select the security group workshop67-fcaj-FargateContainerSecurityGroup-SFP7Slg2FV2i
- Select Deploy

- Configure Load Balancing
- Select Application Load Balancer
- Select Use an existing load balancer
- Select alb-STACK_NAME
- Configure Listener (Port: 8080 and Protocol: HTTP)
- Create Target group, enter
microservice-tg
- Health check path, enter /
- Health check grace period, enter 300

- Thus, we have successfully created and deployed the service.

- After the Microservice service is deployed, we check the website interface and perform a test like.

- We use the browser to access the website. Recheck the CloudWatch logs and it should display “Like processed.”

- Remove the endpoint from the monolith using VSCode.
- In the monolith folder, open mythicalMysfitsService.py and find the following code:
# increment the number of likes for the provided mysfit.
@app.route("/mysfits/<mysfit_id>/like", methods=['POST'])
def likeMysfit(mysfit_id):
serviceResponse = mysfitsTableClient.likeMysfit(mysfit_id)
process_like_request()
flaskResponse = Response(serviceResponse)
flaskResponse.headers["Content-Type"] = "application/json"
return flaskResponse
You can delete or comment out the code.

- After that, we rebuild the monolith image
cd ~/environment/amazon-ecs-mythicalmysfits-workshop/workshop-1/app/monolith-service
docker build -t monolith-service:nolike2 .

- Perform tag assignment and push to the monolith ECR repository.
docker tag monolith-service:nolike2 $MONO_ECR_REPOSITORY_URI:nolike2
docker push $MONO_ECR_REPOSITORY_URI:nolike2

- Check the monolith repository on ECR, we will see the image pushed with the tag nolike2.

- Now, create a final Task Definition for the monolith to reference this Container Image URI and update the monolith service to use the new Task Definition and ensure the application still works as before.