Adopting a declarative approach – Programmatic Approach to IaC with AWS CDK

Once the needs grow beyond basic scripting solutions, organizations typically take the next steps with more advanced services such as CloudFormation and Terraform. In some cases, they might even adopt these services directly, depending on the existing experience and knowledge within the company.

These services offer a declarative approach to infrastructure definition, where the user defines a target state of their AWS accounts. The tools then leverage the underlying service APIs to make thisdeclared state a reality. Reaching this target state requires a lot of magic behind the scenes in terms of state management, resolving update conflicts, dependency resolutions, and so on. All of these are abstracted from the end user.

To get started with these tools, the users need to ramp up on respective configuration languages and template structures. It’s important to note that these services don’t go beyond what is put in the template files. So, the user still needs to define all the components of the architecture at the most granular level and tie them up so that they work together as a solution.

Modifying any of these attributes, such as ImageId or ami, will result in an instance upgrade, but this is entirely handled by the respective tools, while the user just focuses on defining the target state of the infrastructure.

Using infrastructure definition generators

Unlike service-native configuration languages, there is a different segment of tools that offer the flexibility to use regular programming languages, such as Python or Golang, to generate AWS CloudFormation templates. These are beneficial when organizations have a high maturity and comfort level with specific programming languages.

Tools such as Troposphere and GoFormation are well -known in this space and can dynamically generate ready-to-use CloudFormation templates based on the code written by the user.

The teams adopting such tools will still require some understanding of how services such as AWS CloudFormation function under the hood, what kind of constructs (building blocks) they expose to the end user, and so on.

Using frameworks that offer high-level abstractions

Once users are comfortable with services such as AWS CloudFormation and have gained substantial experience debugging production-grade rollouts, they might consider adopting tools such as AWS CDK and Pulumi. AWS CDK offers an approach to managing infrastructure with general-purposeprogramming languages such as TypeScript, Python, Go, Java, and so on. As an official AWS offering, it has some advantages in terms of long-term commitment, support, and development from the cloud provider.

Another famous IaC platform that operates in this space is Pulumi. There are some key differences between how Pulumi and AWS CDK function, but from an end user perspective, the features are more or less the same – infrastructure resource management with commonly used programming languages. Pulumi, like AWS CDK, offers integrations with general-purpose programming languages, but this support is not limited to just AWS. It also provides more than 60+ integrations with other cloud or SaaS providers.

Leave a Comment