# ECS Bluegreen with Lambda SWAP

![Kedarkantha,Uttarakhand,India](/files/-MIO4r26ENNc4uTi7d3o)

### Problem Statement !!

The ask was to create a ECS multiAZ service mesh with load balancer and AutoScaling setup. The Service application should have zero downtime when a new update is rolled out to the service mesh.One click disaster recovery should auto trigger in case if the Unittest suit/UAT for the deployment is not passed in a single shot!!

### My approach to solve this problem

Since the ask was mainly focused around Zero Downtime , I planned out to use following AWS services to overcome this problem.

* ECR
* ECS Cluster
* Load Balancer (Network)
* AutoScaling&#x20;
* EC2
* CodeCommit,CodeBuild,CodeDeploy,CodePipeline
* Lambda
* CloudFormation

The entire infra provisioning is being monitored by CloudFormation nested stack for changes and according lambda is planned to update stack or rollback stack. As ECS ZeroDowntime was a requirement hence a Lambda SWAP application is also planned to switch load between diffrent AZ's and also to maintain Disaster Recovery a terraform stack is planned which remains Hot for onetime deployment and in the mean time the Lambda Application also heals the reported problems in ECS cluster!! AutoRemediation for certain ECS parameters are taken care of in the Lambda Application since it deals with LoadBalancer and EC2 AZ's.

I have used a sample PHP application from AWS for ECR and ECS. Link to [Github Repo](https://github.com/ttn-aditya/ecs-demo-php-simple-app.git)

The entire ECS Application is available at my [Github](https://github.com/ttn-aditya/ecs-application.git)

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ak2019cs.gitbook.io/aditya-kumar/ecs-bluegreen-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
