Examine the evolution of virtualization technologies from bare metal, virtual machines, and containers and the tradeoffs between them.
Install terraform and configure it to work with AWS
Learn the common terraform commands and how to use them
•Terraform Plan, Apply, Destroy
Use Terraform variables and outputs to improve make our configurations more flexible
Explore HCL language features in Terraform to create more expressive and modular infrastructure code.
Learn to break your code into modules to make it flexible and reuseable
Overview of two primary methods for managing multiple Terraform environments
Techniques for testing and validating Terraform code
Covers how teams generally work with Terraform, including automated deployment with CI/CD
In this lesson, we will guide you through the process of installing Terraform, authenticating with AWS, and creating a basic configuration to provision a virtual machine on AWS.
We will also demonstrate how to use Terraform commands to initialize, plan, apply, and destroy resources.
For macOS users, use Homebrew to install Terraform by running brew install terraform.
For other operating systems, visit the HashiCorp Terraform installation page and follow the instructions for your specific OS.
Create a user with the necessary IAM roles for your project. In this example, we used the following permissions:
AmazonRDSFullAccess
)AmazonEC2FullAccess
)IAMFullAccess
)AmazonS3FullAccess
)AmazonDynamoDBFullAccess
)AmazonRoute53FullAccess
)Install the AWS Command Line Interface (CLI) by following the instructions on the AWS CLI installation page.
Run aws configure and enter your access key ID, secret access key, and default region. This will create a credentials file in your home directory at ~/.aws/credentials
.
main.tf
with the following content:terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-011899242bb902164" # Ubuntu 20.04 LTS // us-east-1
instance_type = "t2.micro"
}
Using Terraform Commands:
terraform init
. This sets up the backend and state storage.terraform plan
to view the changes Terraform will make to your infrastructure.terraform apply
to create the specified resources. Confirm the action when prompted.terraform destroy
and confirm the action when prompted.By following these steps, you have installed Terraform, authenticated with AWS, and created a basic configuration to provision a virtual machine on AWS!
You also learned how to use Terraform commands to manage your infrastructure. In the next lessons, we will explore more Terraform features and build out our infrastructure using it.