Software
2025-09-12
6 min
A concise reference to a basic setup of Terraform
This quick Terraform reference guide explores the setting up of AWS and Terraform on your machine and then to create S3 buckets using the Terraform CLI.
Terraform
AWS
Infrastructure as Code
S3
Setup Guide
A reference for getting Terraform
ready to manage AWS resources on a fresh machine. Covers installing dependencies, configuring the AWS CLI, and running the basic Terraform workflow of init
, plan
, and apply
.
đĻPrerequisites
Before running Terraform you need:
- An AWS account with programmatic access enabled.
- The AWS CLI installed and configured.
- Terraform installed on your machine.
- An IAM user for Terraform with appropriate permissions.
đ ī¸Install Tools
- 1Install AWS CLI
Download from AWS or install via your package manager.
bash# Linux/macOS curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip unzip awscliv2.zip && sudo ./aws/install aws --version # Windows (PowerShell, with Chocolatey) choco install awscli aws --version
- 2Install Terraformbash
# macOS with Homebrew brew tap hashicorp/tap brew install hashicorp/tap/terraform # Windows (PowerShell, with Chocolatey) choco install terraform terraform -version
đConfigure AWS Profile
Set up a dedicated profile for Terraform. This keeps its credentials isolated from other AWS use.
bash
aws configure --profile terraform-user
# Paste Access Key + Secret
# Default region: af-south-1 (or your chosen region)
# Output format: json
âšī¸
Use
aws sts get-caller-identity
to confirm the profile works and shows the correct account ID.đRun Terraform
- 1Set environment variablesbash
# Bash export AWS_PROFILE=terraform-user export AWS_REGION=af-south-1 # PowerShell $env:AWS_PROFILE = "terraform-user" $env:AWS_REGION = "af-south-1"
- 2Initialize Terraformbash
terraform init -reconfigure
- 3Review the planbash
terraform plan
- 4Apply the changesbash
terraform apply # Confirm with "yes"
đTroubleshooting
waiting for S3 Bucket ... create: empty result
: Often a propagation delay in opt-in regions. Check if the bucket exists withaws s3api list-buckets
.Cannot import non-existent remote object
: Usually region/profile mismatch or missing IAM permissions (adds3:GetBucket*
actions).AccessDenied
: The error text names the missing IAM action - add it to your Terraform user policy.
Filed under: Terraform, AWS, Infrastructure as Code, S3, Setup Guide