UFO How to Create Unlimited Extra Environments
Have you ever been asked to deploy a branch of code to the staging or uat environment but cannot because the environment is currently in used by someone else or another feature? Usually, you end up having to wait until the environment free. Ultimately, after this happens often enough a common request is to build additional environments. This can take some time though, so you still have to wait.
In version 4 of ufo, a concept of extra environments was introduced to solve this exact scenario. Once you have built at least one environment, you can create identical environments by changing one variable: UFO_ENV_EXTRA
.
Examples
To create more environments.
UFO_ENV_EXTRA=2 ufo ship
You can tell ufo remember the current setting with ufo current
also. Example:
ufo current --env-extra 2
ufo ship
If you need to create the first environment, here are 2 tutorials that show you how to do that:
Create Environments Quickly
If you want to create a lot of environments all at the same time then you want the ufo deploy
command instead of ufo ship
. The ship command builds Docker image and register the ECS task definition every time. With the deploy command it is possible to skip the docker build step. Here’s the command:
ufo deploy --no-wait
The --no-wait
option launches the CloudFormation stack and returns right away. With this you can now do something like this:
for i in {1..10}; do
UFO_ENV_EXTRA=$i ufo deploy --no-wait
done
That just created 10 additional environments. 🎉 It takes about 5 minutes.
Verify Environments
Here’s another loop to check that all the environments are working:
for i in {1..10}; do
curl -s $(UFO_ENV_EXTRA=$i ufo ps | grep 'Elb:' | awk '{print $2}') | sed "s/^/$i: /" &
done | cat | sort -n
If you’re using the test app from UFO ECS Deployment Tool Introduction, you’ll see something like this:
$ for i in {1..10}; do
> curl -s $(UFO_ENV_EXTRA=$i ufo ps | grep 'Elb:' | awk '{print $2}') | sed "s/^/$i: /" &
> done | cat | sort -n
1: 42
2: 42
3: 42
4: 42
5: 42
6: 42
7: 42
8: 42
9: 42
10: 42
Clean Up
Let’s now clean up and remove all the environments:
for i in {1..10} ; do echo $i ; UFO_ENV_EXTRA=$i ufo destroy --no-wait --sure ; done
Summary
That’s it! With that one variable change, an additional ECS service and ELB gets created. The environment has its own endpoint. You will be able to deploy different features or code onto different environments without waiting. Hope you find that helpful!
Thanks for reading this far. If you found this article useful, I'd really appreciate it if you share this article so others can find it too! Thanks 😁 Also follow me on Twitter.
Got questions? Check out BoltOps.
You might also like
More tools:
-
Kubes
Kubes: Kubernetes Deployment Tool
Kubes is a Kubernetes Deployment Tool. It builds the docker image, creates the Kubernetes YAML, and runs kubectl apply. It automates the deployment process and saves you precious finger-typing energy.
-
Jets
Jets: The Ruby Serverless Framework
Ruby on Jets allows you to create and deploy serverless services with ease, and to seamlessly glue AWS services together with the most beautiful dynamic language: Ruby. It includes everything you need to build an API and deploy it to AWS Lambda. Jets leverages the power of Ruby to make serverless joyful for everyone.
-
Lono
Lono: The CloudFormation Framework
Building infrastructure-as-code is challenging. Lono makes it much easier and fun. It includes everything you need to manage and deploy infrastructure-as-code.