I started to use the Swap Environment URLs feature in Elastic Beanstalk (CNAME swap). What is the best approach, if I want to stick to the same environment name?
Currently, I swap twice. First I bring up my changed my-env-new environment. I perform the first cname swap from my-env to my-env-new. Then I delete the previous my-env. I clone the new my-env-new into my-env and swap again. Is there a better way?
I run an AWS external CI/CD pipeline, which uses the environment name to update the environment, hence I need to retain that name. Maybe it's not a best practice to hardcode the environment name in such a pipeline.
Yes, this is pretty much how you do blue/green deployment using EB. The cloning is an integral part of it:
Lambda functions to clone the blue environment as the green environment, to re-swap the URLs, and to terminate the green environment when deployment and testing for the blue environment are complete.
The exact details how to do it in an automated manner are described in AWS whitepaper:
Regarding the hard-coding of the env name, I'm not sure from your question where is it being hard-coded? If you use CloudFormatin for your pipeline, you can pass it as a default parameter to it. This way it is easy to change and re-use your pipeline. If you created pipeline in AWS console, then selection of existing EB application and EB environment are necessary in a deploy stage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With