The elasticity and scalability of the cloud provide lots of opportunity for automation. Some automation tools and services are provided by cloud vendors themselves. AWS, for example, offers CloudFormation for provisioning AWS resources programmatically, Microsoft has its Automation, and OpenStack has Heat. But all those services come with vendor lock: they’ll only deploy within their own environments. But if you’re looking for multi-vendor solutions, then you might be better off with HashiCorp’s open source Terraform, which can provision servers and services from just about any cloud platform.
Besides Terraform, HashiCorp is also the creator of the Vagrant, Packer, Serf, and Consul projects, and the commercial product Atlas.
Use Terraform to launch your application infrastructure
Terraform is meant to help you combine all the components you’ll need to build and launch your application infrastructure. You could, for instance, select a base server from AWS, DNS from cloudfare, and a postgres database from Heroku. Terraform will build a single application framework from across all these providers in parallel.
When you make changes to your configuration file, Terraform determines what needs updating and applies only incremental changes.
Infrastructure as Code:
Your complete infrastructure and services are defined using programmatically and versioned code. Code-defined infrastructure is generally easier to read and share with others.
The execution plan shows exactly what will happen when you apply a particular Terraform configuration, giving you clear visibility into the way your infrastructure will perform.
After your infrastructure has been built by Terraform, you can visualize your resources and gain insight into their dependencies.
Terraform Use Cases
Terraform’s flexibility and power mean that it will work across a very wide range of use cases.
A two-tier app uses a web/application server that’s powered by standalone database servers. Terraform will make sure that your database tier is available before the web servers are started and before attaching web nodes to a load balancer. A web or database tier can be easily scaled by modifying a single count configuration value.
You may want to deploy your application across multiple platforms for fault tolerance or disaster recovery. While many infrastructure orchestration tools are cloud vendor specific, Terraform is cloud-agnostic. By using a single configuration file, you can deploy your application on resources from multiple cloud providers.
Heroku app setup:
We addressed the what is Heroku? question in a previous post. Terraform can be used to codify the Heroku application set up the process, ensuring that all required add-ons (like configuring DNSimple to create a CNAME record or setting up cloudfare as your CDN) are available.
You can provide a sample Terraform configuration file to create, provision and bootstrap a demo on cloud providers like AWS to your end users and clients, who could also quickly tweak resource parameters according to their needs.
In an SDLC process you will create environments like QA, Staging, Load Testing, and Production. Some of these environments don’t always have to be running. As your Terraform-based infrastructure is code-based, you can easily build and destroy your infrastructure according to need.
If you need reliably reproducible environments across your application life cycle, Terraform configurations can be dropped in (and out) on demand to build staging, QA or dev deployments.
Software Defined Networking:
AWS VPCs, for example, are among the most commonly used SDN implementations and can be codified by Terraform.
Installing Terraform (Linux)
Here’s how you can very quickly and simply install Terraform on your Linux system. There are also 32 and 64-bit packages available for Mac OS X, Windows, FreeBSD, and OpenBSD.
- Download the appropriate package for your OS.
- Add Terraform to your system path.
- Verify the installation by typing terraform on your command prompt
The following cloud providers are supported by Terraform:
- Amazon Web Services
- Microsoft Azure
- Google Cloud
Deploying a two-tier application on AWS using Terraform
Now that Terraform is installed on your Linux system, use this simple “terraform init” example from your command prompt to quickly deploy a two-tier application to AWS (note: you may incur usage costs from AWS as a result).
terraform init github.com/hashicorp/terraform/examples/aws-two-tier
To generate and show an execution plan, run
cd into your git-cloned directory and then run
Terraform will interactively ask for account authentication and access data like your AWS Keys, Region, and AMI. Your resources will be provisioned on AWS and a sample nginix application will be deployed on those servers.
When you are done, clean up your resources by running
If you’d like to learn more on Terraform, this is your go-to learning material on the topic:
Do you have your own experiences with or plans for Terraform? Let us hear from you in the comments.
AWS Security: Bastion Host, NAT instances and VPC Peering
Effective security requires close control over your data and resources. Bastion hosts, NAT instances, and VPC peering can help you secure your AWS infrastructure. Welcome to part four of my AWS Security overview. In part three, we looked at network security at the subnet level. This ti...
Top 13 Amazon Virtual Private Cloud (VPC) Best Practices
Amazon Virtual Private Cloud (VPC) brings a host of advantages to the table, including static private IP addresses, Elastic Network Interfaces, secure bastion host setup, DHCP options, Advanced Network Access Control, predictable internal IP ranges, VPN connectivity, movement of interna...
Big Changes to the AWS Certification Exams
With AWS re:Invent 2019 just around the corner, we can expect some early announcements to trickle through with upcoming features and services. However, AWS has just announced some big changes to their certification exams. So what’s changing and what’s new? There is a brand NEW ...
New on Cloud Academy: ITIL® 4, Microsoft 365 Tenant, Jenkins, TOGAF® 9.1, and more
At Cloud Academy, we're always striving to make improvements to our training platform. Based on your feedback, we released some new features to help make it easier for you to continue studying. These new features allow you to: Remove content from “Continue Studying” section Disc...
AWS Security Groups: Instance Level Security
Instance security requires that you fully understand AWS security groups, along with patching responsibility, key pairs, and various tenancy options. As a precursor to this post, you should have a thorough understanding of the AWS Shared Responsibility Model before moving onto discussi...
Cloud Migration Risks & Benefits
If you’re like most businesses, you already have at least one workload running in the cloud. However, that doesn’t mean that cloud migration is right for everyone. While cloud environments are generally scalable, reliable, and highly available, those won’t be the only considerations dri...
Real-Time Application Monitoring with Amazon Kinesis
Amazon Kinesis is a real-time data streaming service that makes it easy to collect, process, and analyze data so you can get quick insights and react as fast as possible to new information. With Amazon Kinesis you can ingest real-time data such as application logs, website clickstre...
Google Cloud Functions vs. AWS Lambda: The Fight for Serverless Cloud Domination
Serverless computing: What is it and why is it important? A quick background The general concept of serverless computing was introduced to the market by Amazon Web Services (AWS) around 2014 with the release of AWS Lambda. As we know, cloud computing has made it possible for users to ...
Google Vision vs. Amazon Rekognition: A Vendor-Neutral Comparison
Google Cloud Vision and Amazon Rekognition offer a broad spectrum of solutions, some of which are comparable in terms of functional details, quality, performance, and costs. This post is a fact-based comparative analysis on Google Vision vs. Amazon Rekognition and will focus on the tech...
New on Cloud Academy: CISSP, AWS, Azure, & DevOps Labs, Python for Beginners, and more…
As Hurricane Dorian intensifies, it looks like Floridians across the entire state might have to hunker down for another big one. If you've gone through a hurricane, you know that preparing for one is no joke. You'll need a survival kit with plenty of water, flashlights, batteries, and n...
Amazon Route 53: Why You Should Consider DNS Migration
What Amazon Route 53 brings to the DNS table Amazon Route 53 is a highly available and scalable Domain Name System (DNS) service offered by AWS. It is named by the TCP or UDP port 53, which is where DNS server requests are addressed. Like any DNS service, Route 53 handles domain regist...
How to Unlock Complimentary Access to Cloud Academy
Are you looking to get trained or certified on AWS, Azure, Google Cloud Platform, DevOps, Cloud Security, Python, Java, or another technical skill? Then you'll want to mark your calendars for August 23, 2019. Starting Friday at 12:00 a.m. PDT (3:00 a.m. EDT), Cloud Academy is offering c...