We have created stacks. We have updated them manually to Amazon S3. We can launch them easily from the AWS Console > CloudFormation View.
Now it is time to use some CI/CD scripts which will deploy our micro-services in one(zero) click. You can put this scripts either on Git or on Jenkins or whatever tool you want to use, it is up to you.
Let’s say we have the micro-service called ‘product1’ for ‘tenant1’ to deploy while it’s stack is already created on Amazon.
The first thing first, we build the docker image with the application inside and push it to Amazon ECR.
To push it, you can do the following:
1. First get the login command and run it:
$loginCommand=aws ecr get-login --no-include-email
2. Tag and push the image:
docker tag ImageName AMAZON_ACCOUNT.dkr.ecr.REGION.amazonaws.com/REP
docker push AMAZON_ACCOUNT.dkr.ecr.REGION.amazonaws.com/REP
And finally, just update the cloud formation stack with the new image you just pushed to deploy it:
aws cloudformation update-stack --stack-name product1-stack ` --template-url https://s3-REGION.amazonaws.com/product1-stack.yaml ` --capabilities CAPABILITY_IAM ` --parameters ParameterKey=Image,ParameterValue=AMAZON_ACCOUNT.dkr.ecr.REGION.amazonaws.com/REP
And that is all you need to do to do a deploy to production of your micro-service.