Chrome Dev Summit 2017 is behind us. I spent most of the run-up to the event putting together my “Workbox: Flexible PWA Libraries” talk, but beyond that, I was also involved in running on-site…
As someone who constantly works with AWS environments, Cloudformation has been one of my weapons of choice for deploying resources for quite some time now.
So how can we govern ordering, both between stacks and between individual resources within those stacks?
Cloudformation offers a dependency management mechanism out of the box through the DependsOn
attribute that can be attached to any resource, explicitly instructing the orchestrator to wait for any number of dependent resources to be provisioned before a creation or update is initiated. We can piggyback on this to enable conditional ordering by using the approach outlined below.
In the example below we have an app, its bootstrap process depends on a database being present so that some data can be seeded.
The problem at hand is that if we opt to launch an Aurora DB, we want the DB to be launched before the Application is provisioned, in similar circumstances we could opt to enforce the ordering by creating an static dependency as follows:
DependsOn: Aurora
The main blocker in this case is that his would work only if we were certain that the Aurora resource will always be provisioned.
In our use-case whether the resource gets provisioned or not will depend on the UseAurora
parameter we set when we deploy the Cloudformation stack. The way to handle this unknown outcome is to introduce conditional ordering, we do this by telling Cloudformation to enforce ordering but only when a specific condition is met.
We will attach a tag to our app resource for which we conditionally populate the value; if the ExternalDB
condition resolves to True
we will set its value to the Aurora stack name (extracted from its ARN, through the Select
intrinsic function). The use of a !Ref
invocation will cause the referenced resource to be provisioned before the resource that is referencing it, if on the other hand the condition returns as false we will populate the tag with some text- this will also mean that launching our app will not depend on any other resource.
Shopify and WordPress are popular platforms for building and managing an online store. WordPress Shopify integration these platforms can help you take advantage of the best features of each and boost…
Clean beauty is a growing trend in the beauty industry that focuses on using products that are free from harmful chemicals and toxins. The clean beauty movement has gained momentum in recent years…
Are you looking to obtain a concealed carry permit in Arizona, but struggling to find the time or resources to attend an in-person course? Look no further than online concealed carry courses. With…