This is a short tutorial on using Terraform with AWS. It assumes some basic knowledge of Terraform.
You'll need an [Amazon Web Services account][https:/aws.amazon.com/), the AWS CLI, Git, and Terraform.
You'll also need something to edit Terraform files, preferably with some syntax highlighting, etc. Some plugins / modes / extensions for common editors:
- Atom
- Emacs
- JetBrains Editors (IntelliJ IDEA, PyCharm, WebStorm, PhpStorm, etc.)
- Nano
- Sublime Text 3
- TextMate
- VIM
- Visual Studio Code
You'll need to install some tools before starting this tutorial:
aws
- the Amazon command line client is useful for configuring AWS profiles, credentials, and optionsgit
- version (source code) tooljq
- command line JSON toolterraform
- command line tool for managing infrastructure resources
- Install Homebrew
- Use Homebrew to install Terraform, the AWS CLI, jq, and a newer version of git
% brew update
% brew install awscli git jq terraform
-
Install curl, git, groff, jq, pip3 (Python3), and unzip
-
APT based
% sudo apt-get update % sudo apt-get install curl git groff jq python3-pip unzip
-
YUM based
% sudo yum update % sudo yum install curl git groff-base jq python3-pip unzip
-
Alpine
% sudo apk update % sudo apk add curl git groff jq python3 unzip
-
-
Install the AWS CLI
% sudo pip3 install awscli
-
Install Terraform
% cd /usr/local/bin % curl -so /tmp/terraform.zip https://releases.hashicorp.com/terraform/0.12.26/terraform_0.12.26_linux_amd64.zip % sudo unzip /tmp/terraform.zip % rm /tmp/terraform.zip
- You can find the latest version of Terraform for 64 bit Linux at https://releases.hashicorp.com/terraform/
I rarely use Windows, but here are some starting points
You should create a Terraform IAM User in your AWS account, and grant that user full admin rights. This video shows the steps to take in the AWS Console to create a new IAM user with credentials and the correct policy:
- Create new IAM user (called
terraform
) - Attach the AdministratorAccess policy to the user
- Create and download credentials for the user