Create ECS Service
- Also in the newly created Task interface, we will create an ECS service to run the newly created Task definition.
- Select Deploy
- Select Create Service
- Setting up the environment
- Select cluster (Cluster-STACK_NAME)
- Perform configuration *Deployment
- Application type, default Service
- Perform naming Service name
- Desired tasks, choose 1
- Configure Load Balancing
- Select Application Load Balancer
- Select Use an existing load balancer
- Select alb-STACK_NAME
- Configure Listener (Port: 80 and Protocol: HTTP)
- Create Target group, enter
- Health check path, enter /
- Health check grace period, enter 300
- Configure Network
- VPC, select Mysfits-STACK_NAME
- Subnets, choose private subnet
- Go to Security group, select Use an existing security group
- We choose Security group default and make sure to configure inbound HTTP (port 80)
- Select Deploy
- Thus, we create the service deploy successfully.
- After the Microservice service deploys, we test the website interface and perform the like test.
- We use the browser to access the website. Check CloudWatch logs again and show “Like processed.”
- Implement endpoint removal from monolith using Cloud9.
- In the monolith folder, open mythicalMysfitsService.py find the following code:
# increment the number of likes for the provided mysfit.
serviceResponse = mysfitsTableClient.likeMysfit(mysfit_id)
flaskResponse = Response(serviceResponse)
flaskResponse.headers["Content-Type"] = "application/json"
- Then we build a monolith image
docker build -t monolith-service:nolike2 .
- Perform tag assignment and push to monolith ECR repository.
docker tag monolith-service:nolike2 $MONO_ECR_REPOSITORY_URI:nolike2
docker push $MONO_ECR_REPOSITORY_URI:nolike2
- Check monolith repository on ECR, we will see that the image is pushed with the tag nolike2.
- Now make one last Task Definition for the monolith to refer to this new container image URI (this process should be familiar now, and you can probably see that it makes sense to leave this drudgery to a CI/CD service in production), update the monolith service to use the new Task Definition, and make sure the app still functions as before