ECS Blue/Green deployment was successful using CodePipeline. However, Blue and Green target groups point to the same instance.
My ECS has one instance, which Target Group A points to.
When CodePipeline triggers a new version deployment: My prediction was that AutoScaling would create a new instance, Target Group B would point to a new instance, and ALB would point to Target Group B.
However, the actual result was that no new instance was created, and a new version of the container was created within the original instance, and Target Group B was pointing to this container.
What this means is that one instance always needs twice as many resources.
Alternatively, there is a way to create two instances in ECS and use each in the Blue and Green versions, but this is also unnecessarily double-wasting resources all the time.
The requirement I want is to dynamically create a new instance only when a new version is needed, and usually only one instance exists.
For example, if my service requires 300MB of memory, a 512MB instance is enough. If a new version needs to be deployed, create a new 512MB instance and have two 512MB instances 'only for a moment'. When the Blue version goes down, there is only one 512MB instance of the Green version again. However, it seems that we need to keep one 1024MB instance running all the time so that Blue and Green can exist at the same time, or that two 512MB instances should be running all the time.
How can I configure it to meet my requirements? Did I understand ECS Blue/Green distribution correctly?