We already published the article about IaC, particularly about Terraform. However, there are so many nuances in each development case, that sometimes we need to find alternative solutions for similar tasks. Some services (in our case it’s Amazon Web Services) can offer various components for software development and server administration. That’s why AWS also offers the most comfortable way of dealing with all those components at once within one infrastructure. The example of such approach is CloudFormation that manages configurations and enables automation. It is a beneficial tool that makes work of developers and operations simple and fast.
IaC in the Context of DevOps
IaC allows implementing DevOps practices during software development. Вlurring of distinctions between development and operations, their collaboration, and automation of processes are primary goals in DevOps to achieve high productivity and efficiency. That’s why IaC tools are essential for it.
IaC implies managing large-scale configurations with the help of automation. The software cares about data center components (servers, storage, networks, virtual machines, load balancers, etc.), in means of specific files that are read by the software and processed to set up the infrastructure as required. The main advantages are:
- the absence of manual work that accelerates the configuration and excludes errors, and lets developers focus on creative work;
- The configurations are represented as code and you can hold it versioned in a repository.
Teams that implement IaC can deliver stable environments rapidly and at scale.
AWS CloudFormation is a declarative template-based infrastructure as code service that allows the configuration and provisioning of AWS resources (it does not work with other components). If you asked professionals to tell you why they preferred the service, they would probably tell you that it has a good UI, enables you to see all your stacks for a given account, ensures a smooth cross stack referencing, and has much bigger coverage in terms of AWS services unlike Terraform or other IaC solutions.
CloudFormation offers you sample templates, or you can create your templates along with other parameters required to run the app such as dependencies or runtime. You don’t have to think in what order to provision AWS services or how to arrange dependencies. With that DevOps engineers can easily handle the configuration of Elastic Beanstalk, EC2 instance, RDS, security groups. Moreover, it manages the dependencies among them, set their connection, put it in one template.
How It Works
Its basic components are templates and stacks.
At first, you choose whether you’d like to work with a sample template or to create your own describing the AWS resources, dependencies among them, and required parameters. A template is presented as a text file in JSON or YAML and contains such information as description, metadata, parameters, mappings, conditions, resources, output. You describe all the needed settings in it and then submit to CloudFormation that forms and organizes the necessary resources. Then it configures a stack based on your template. And we get a ready-to-use environment in the cloud. After the stack is created, the user still can edit the prior configurations.
In short, it offers such features:
- Authoring with JSON/YAML;
- Safety Controls;
- Preview Changes To Your Environment;
- Dependency Management;
- Cross Account And Cross-Region Management;
The traditional tools for configuration management work only from the operating system layer and up. However, when you work with the cloud, you are required to provision both the app and its cloud infrastructure. The latter is much more complicated because the number of moving parts around your application is continuously growing and they are evolving. So AWS CloudFormation tries to help you here.
- First of all, you put your infrastructure together in a single text file. In such a way, you get a unified and standardized solution for the infrastructure components. Anyone who works on the same project gets the same configurations which speed up the collaboration and make easier troubleshooting.
- CloudFormation knows what operations to perform and when to rolls back changes in case of errors. You do not have to do any manual setups while developing your app’s infrastructure as well as write scripts.
- Since the service implies infrastructure as code model, software engineers have to deal with code. That means that you can work in your preferred code editor, check it into a version control system, apply CI/CD for it, and review the files with your development team before deployment.
A Few More Words
The market offers a lot of decent solutions to create an infrastructure and configure resources including CloudFormation. It covers almost all AWS resources, which is not the case for most of its competitors (Terraform, for example). A significant benefit in using CloudFormation is automation and provisioning that are done in simply and quickly without asking you to pay more than just for AWS resources required to run your applications. Also, the service is ready to grow along with your app’s needs. CloudFormation still has a room to grow, but it also can be a trusted and reliable partner for implementing IaC.