What is the name of AWS native infrastructure as code solution to repeatable deployments?
Skip to content
Show
Introduction to IaC and AWS Native tools like CloudFormation and CDKHome/Cloud/Introduction to IaC and AWS Native tools like CloudFormation and CDK Introduction to IaC and AWS Native tools like CloudFormation and CDK1. Introduction to Infrastructure as Code (IaC)IaC is a methodology that allows us to define, through coding, the resources that make up our infrastructure and the relationships between them. Managing the infrastructure as if they were pieces of source code is one of the fundamental principles of the DevOps philosophy since it allows us to take advantage of the best practices associated with software design refined during years of development, to leverage them to provision and manage infrastructure. This way, we can manifest our infrastructure through code files that will be reusable, shareable and versionable, ensuring that the environments created are more robust, reliable, easy to maintain and manage and, above all, repeatable. 2. Declarative Model vs Imperative ModelThe main difference between the declarative model and the imperative model is to be able to distinguish between the ‘What’ and the ‘How’. With a declarative paradigm, the focus is the end goal, the flow of the program and the underlying logic are of lesser importance. An example would be “I want three instances”. With an imperative paradigm, control structures are built and logic is paramount. For example, “Build one instance and repeat until there are three”. As they don’t have an underlying logic in the code, declarative scripts (which in the case of Infrastructure as Code are akin to text files specifically formatted in YAML or JSON) tend to be longer but also easier to read and therefore to maintain and build. On the other hand, imperative scripts are not necessarily difficult to write, but having embedded logic makes maintaining them belong in the same category as maintaining software, requires attention to the interactions between program components, and is generally somewhat more time-consuming to maintain. 3. CloudFormationAWS’ own IaC tool, CloudFormation is a native service that automates the deployment of resources in AWS and uses templates to declare resources. It is the vendor’s recommendation to provision infrastructure in different environments or accounts and manage resources, although it is not the only one that can be used. CloudFormation plays an important role in helping us distribute solutions regardless of environment, account or region. Learning CloudFormation is not complicated once some basic concepts of the service (Templates, Stacks, Change Sets) are understood and the user is able to adapt to the syntax of the configuration files. By mastering this, complex solutions can be deployed, replicated and distributed in a very short time. It is a free service and only incurs expenses with the services and resources deployed, making it a tool that manages our infrastructure without any charge for the service as such. When for some reason it is not possible to deploy the infrastructure and there is any inconsistency in the deployment process, the system can perform automatic rollbacks: CloudFormation attempts to undo any changes that may have occurred during the execution and return the infrastructure to its pre-deployment state, including checking dependency between resources before deletion or upgrading. A Drift detection feature analyses what we want to deploy and what we currently have deployed and is very useful to detect cases of click ops in an environment, which is quite difficult to perform in a large infrastructure. 4. CDKCDK uses a programming language that minimizes traditional configuration files. This results in less code that does the same or more using the language of choice for our IaC: whether it is TypeScript, Python or JavaScript. By writing less code maintenance is reduced, it is easier to share it and above all it makes it easier and faster to grasp. A good example of this can be the creation of networking resources for an account or the maintenance of an API with many endpoints in Api Gateway. The common factor of all programming languages supported by CDK is that they get along excellently with object oriented programming, this allows for more abstraction and inherits benefits of this paradigm beyond portability and reusability of our code as is the ability to create pieces of architecture that reduce complexity to the user without compromising flexibility and configuration required; also being able to easily extend specific functionalities on demand without much effort.
Packaging the solution or infrastructure product and making a delivery that can be used by anyone with very little configuration is achieved through CDK Constructs. They are used to create resources such as an S3 Bucket or an entire infrastructure such as an API with persistence and a Cloudfront distribution. We can create our own Constructs according to requirements and thus apply the DRY concept because if a solution is consistently reused we can package it and distribute it to different work teams. CDK includes a testing library which is usable for code assertions, however it is prepared so that it can be tested and depending on the language used, it can be combined with the currently used test suite. With pytest functionality can be extended from an internal CDK test library with more complex test cases. In fact, the recommendation from AWS is that the tests are to be kept uncomplicated, evaluating simple code behaviors, but as the Stacks grow and with them complexity, the ideal scenario is that the tests are able to recognise if there are negative consequences to our modifications so they can be fixed before testing. 5. Drawbacks
Related PostsWhat tool does AWS use for infrastructure as code?HashiCorp Terraform Enterprise
Provides infrastructure automation as a service with IaC for provisioning, compliance, and management of any infrastructure on AWS.
Which solution provides a fast automated repeatable method of deploying AWS cloud infrastructure to multiple AWS regions?AWS CloudFormation streamlines the deployment of key workloads on the AWS Cloud. With AWS CloudFormation, you model and provision all the resources needed for your applications across multiple Regions and accounts in an automated and secure manner.
Is AWS CDK infrastructure as code?Improve infrastructure and business logic
Develop applications more efficiently using AWS CDK as the main framework to define cloud infrastructure as code.
Which AWS service allows users to provision resources using a consistent and repeatable process?Maintaining consistent infrastructure provisioning in a scalable and repeatable manner becomes more complex as your organization grows. With AWS CloudFormation, you can easily model your infrastructure resources with code to enable configuration compliance and faster troubleshooting.
|