Requires an AWS account. The example uses a free tier EC2 instance. If you do not have free tier example, this example would likely not incur any costs over $3.
This is a shortened "getting started" version of the official Terraform documentation.
- From console,
brew install terraform
terraform --version
to check if installed correctly- Install AWS CLI using the bundled installer
cd ~/Downloads
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
aws --version
to check if installed correctly
- To verify your AWS profile and esure Terraform as correct provider credentials
- Run
aws configure
- The credentials for this stage can be found or set up here
- Run
- Create Terraform configuration file
- cd to your desired working directory
- Create an
example.tf
file with the following:provider "aws" { profile = "default" region = "us-east-1" } resource "aws_instance" "example" { ami = "ami-2757f631" instance_type = "t2.micro" }
- Replace
region
with your desired region - Replace
ami
with an AMI that exists in your desired region (AMI Id's are different between regions)
terraform validate
to check Terraform config for errorsterraform init
to download the AWS provider pluginterraform apply
to begin the process of applying the the configuration