Feb 10, 2019 | AWS
Automating infrastructure deployment on Amazon Web Services
As the world moves to Cloud Computing, provisioning infrastructure can be done with a few clicks on the consoles of various public cloud providers such as Amazon Web Services (AWS), Google Cloud Platform (GCP) and Microsoft Azure (Azure). Developers and IT personnel can setup and tear down infrastructure using command line or web portals. Compare that to the long tedious process of provisioning infrastructure in Data Centers.
With this ease of infrastructure deployment – managing the version of infrastructure just as we manage software code for programs using Git or SVN has become necessary. When you search for Infrastructure as Code (IaC) you will have every major technology company provide their definition. I will refer you to a definition that Martin Fowler provided in his blog post InfrastructureAsCode:
Infrastructure as code is the approach to defining computing and network infrastructure through source code that can then be treated just like any software system.
Martin refers to growing up in Iron Age the notion that to release new software you had to find physical hardware in your data center.
Getting started in creating infrastructure on AWS
Even before you attempt to automate or use IaC for infrastructure creation and management in AWS (and there are plenty of tools, frameworks available both from AWS and third parties) – it is best to get started on the AWS Console first. This will give you a visual idea on what you are about to create, and what steps are involved. Moving to IaC will be easier because you know that these steps need to be carried out explicity in the IaC toolkit or framework, or some of would be setup implicitly as default.
After getting hands-on experience with AWS Console, you should explore the following:
- Start with the AWS Command Line Interface (AWS CLI). This is the workhorse to quickly check or get information on resources in your AWS account. And of course a good mechanism of creating resources without having to use your mouse, and logging on to the AWS Console.
- The challenge with AWS CLI is that you cannot track the changes you made or the sequence you followed. All of that is manual. In reality it is not much of an automation, except you no longer need to login to the Console, and navigate using a mouse. The next thing to get comfortable with is building Python scripts using Boto3. Boto3 is the Python SDK for AWS and it allows you to directly create, update, and delete AWS resources from your Python scripts. Please note that you are not restricted to Python/Boto3 – AWS makes SDKs available in all popular languages, take a look here.
3 Ways to automate creating infrastructure in AWS with AWS tools & services
- AWS CloudFormation automates the provisioning of your AWS infrastructure. Once you’ve specified your infrastructure in a reusable JSON or YAML template, CloudFormation provisions your resources in a safe, repeatable manner, removing the need for manual actions or custom scripts. It is the defacto mechanism or service to provision resources since the three following IaC tools outlined below – all convert their respective outputs to CloudFormation templates prior to actually creating (or editing, updating, deleting) infrastructure in AWS.
- AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings. With just a few lines per resource, you can define the application you want and model it using YAML. During deployment, SAM transforms and expands the SAM syntax into AWS CloudFormation syntax, enabling you to build serverless applications faster.
- AWS Cloud Development Kit (CDK) With the AWS Cloud Development Kit (AWS CDK), you can define your cloud environment using TypeScript, Python, Java, and .NET. AWS CDK is an open-source software development framework that helps you model cloud application resources using familiar programming languages, and then provision your infrastructure using CloudFormation directly from your IDE. CDK provides high-level components that preconfigure cloud resources with proven defaults, so you can build cloud applications without needing to be an expert.