Working with Multiple CloudFormation Stacks Just Got Easier!

Working with Multiple CloudFormation Stacks Just Got Easier!

Managing your cloud infrastructure as code is a core philosophy at TriNimbus. Amazon Web Services' CloudFormation service enables the creation of multi-tier AWS resource collections that developers and sysadmins provision, manage and update in a manner that supports this philosophy.

CloudFormation Templates and Stacks

Using CloudFormation templates, developers specify the AWS resources, dependencies and runtime parameters for a CloudFormation stack for your applications. CloudFormation takes care of AWS resource provisioning and the reconciliation of dependencies. Since templates are text-based files, they may be managed under version control just as you do for your software.

Until recently, two points of friction existed that made CloudFormation development problematical: readability of CloudFormation templates and the ability to orchestrate multiple CloudFormation templates or stacks via parameter passing. AWS has addressed both these issues with recent updates, which are described here.

Maintainability of CloudFormation Templates Improved

Until the most recent CloudFormation update, templates were represented in JSON, which lacks a native manner to add comments within the templates. Deeply nested data structures in JSON can be particularly hard for developers to parse visually.

Typically, the solutions involve separate descriptive text files or writing the templates in a language that supports comments, such as YAML, and then translating this code to JSON. Clearly, both these methods negatively impact the creation and maintenance of CloudFormation templates.

The latest AWS CloudFormation update now enables the use of YAML templates directly. The forest of curly braces typical of complex JSON code is thus eliminated and documentation can be supplied inline.

Cross-Stack Parameter Passing

Large, multi-application virtual data centers often utilize several CloudFormation stacks in a tiered architecture. One way in which AWS CloudFormation supports creation of complex architectures is by enabling templates to pass stack input parameters, which increases template reusability.

Parameter transfers can support stack decoupling by allowing stacks to pass information down the run order via stack input and output parameters. This feature lets developers create modular architectures providing finer runtime control and reuse of stack capabilities.

This AWS CloudFormation update has made orchestrating templates and stacks easier for developers by introducing cross-stack references, which simplify referencing resources created by other stacks. Related AWS resources can be specified within stacks, any of which may be designated as outputs. These outputs are consumed as inputs by any other stack requiring the information for its operation.

The update provides a new Export output field that selects a value for export. A stack consuming the value uses the intrinsic function Fn::ImportValue to import it. Note that Export names must be region unique, export values must not use resource-dependent functions and a stack cannot be deleted if another stack is using its outputs. Visit AWS' complete walk-through of cross-stack parameter passing for complete details.

This new feature obviates the need for complex workarounds such as the use of external code to extract output values (e.g. the Ansible cloud_formation_stack_facts plugin), AWS Lambda-backed custom CloudFormation resources or the use of a limited set of environment variables.


The new CloudFormation features described above further empower CloudFormation's ability to specify and manage your cloud application infrastructure in the same manner as your software code and documentation. The inability to document JSON code and painful workarounds for orchestrating CloudFormation templates and stacks are efficiency impediments no more for your AWS developers. As heavy users of AWS CloudFormation, TriNimbus is particularly pleased with these improvements so they can more effectively serve their customers and deliver the benefits of automation.

No Comments Yet.

Leave a comment