Terraform VSCode Extension: Syntax Highlighting, Autocomplete, and Formatting
Install and configure the HashiCorp Terraform VSCode extension. Enable syntax highlighting, autocomplete, format on save, validation
Cloud Computing
Install AWS CLI v2 on macOS with Homebrew in 2 commands: brew install awscli. Includes configuration, credential setup, troubleshooting common errors
brew install awscli
aws --version
aws configureThat's it. Read on for configuration, troubleshooting, and advanced setup.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"brew updateThis ensures you get the latest version of the AWS CLI package.
brew install awscliHomebrew installs AWS CLI v2 and all dependencies automatically. Takes 1-2 minutes.
aws --versionExpected output:
aws-cli/2.17.x Python/3.12.x Darwin/24.x source/arm64If you see a version number, the installation worked.
aws configureYou'll be prompted for four values:
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: jsonIf you use multiple AWS accounts:
# Create a profile for work
aws configure --profile work
# Create a profile for personal
aws configure --profile personal
# Use a specific profile
aws s3 ls --profile work
# Set default profile for the session
export AWS_PROFILE=work# Verify your identity
aws sts get-caller-identityExpected output:
{
"UserId": "AIDAEXAMPLE",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/your-username"
}# List S3 buckets
aws s3 ls
# List EC2 instances
aws ec2 describe-instances --query "Reservations[].Instances[].{ID:InstanceId,State:State.Name}" --output table# Upgrade to the latest version
brew upgrade awscli
# Check the new version
aws --versionbrew uninstall awscliIf you prefer the official installer:
# Download the macOS installer
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
# Install
sudo installer -pkg AWSCLIV2.pkg -target /
# Verify
aws --versionThe Homebrew method is easier to manage (upgrade/uninstall), which is why we recommend it.
Homebrew didn't add aws to your PATH. Fix:
# For Apple Silicon Macs (M1/M2/M3)
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# For Intel Macs
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcUnable to locate credentials. You can configure credentials by running "aws configure".Run aws configure and enter your access keys. Or check that your credentials file exists:
cat ~/.aws/credentialsAn error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation:
The security token included in the request is invalid.Your access key is wrong or deactivated. Generate a new one in the IAM Console.
If using temporary credentials (SSO, assume role), refresh them:
aws sso login --profile your-profileIf aws --version shows v1 after installing v2:
# Check which aws binary is being used
which aws
# If it's /usr/local/bin/aws (old v1), remove it
sudo rm /usr/local/bin/aws
# Homebrew's version should now take priority
aws --version# Fix permissions
sudo chown -R $(whoami) /opt/homebrew
# or for Intel Macs:
sudo chown -R $(whoami) /usr/localAWS CLI stores config in two files:
# Credentials (access keys)
~/.aws/credentials
# Configuration (region, output format)
~/.aws/configExample ~/.aws/credentials:
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[work]
aws_access_key_id = AKIAI44QH8DHBEXAMPLE
aws_secret_access_key = je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEYExample ~/.aws/config:
[default]
region = us-east-1
output = json
[profile work]
region = eu-west-1
output = tableOnce AWS CLI is configured, Terraform uses the same credentials automatically:
provider "aws" {
region = "us-east-1"
# Terraform reads ~/.aws/credentials automatically
# Or use a named profile:
# profile = "work"
}Verify Terraform can access AWS:
terraform init
terraform plan# S3
aws s3 ls # List buckets
aws s3 cp file.txt s3://bucket/ # Upload file
aws s3 sync . s3://bucket/ # Sync directory
# EC2
aws ec2 describe-instances # List instances
aws ec2 start-instances --instance-ids i-12345 # Start
aws ec2 stop-instances --instance-ids i-12345 # Stop
# IAM
aws iam list-users # List IAM users
aws iam get-user # Current user info
# CloudFormation
aws cloudformation list-stacks # List stacks
# Output formatting
aws ec2 describe-instances --output table
aws ec2 describe-instances --output json
aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId"Learn by doing with interactive courses on CopyPasteLearn:
Installing AWS CLI on macOS with Homebrew is the simplest method: brew install awscli. Configure it with aws configure, test with aws sts get-caller-identity, and you're ready to manage AWS from your terminal. Use brew upgrade awscli to keep it updated. Terraform picks up the same credentials automatically, so once AWS CLI works, Terraform works too.
Install and configure the HashiCorp Terraform VSCode extension. Enable syntax highlighting, autocomplete, format on save, validation
Configure Terraform remote state with AWS S3 and DynamoDB locking. Complete setup with encryption, versioning, IAM permissions, and team access patterns.
Protect your applications with AWS WAF rules managed by Terraform — rate limiting, IP blocking, and SQL injection prevention.
Manage secrets securely with AWS Secrets Manager and Terraform — rotation, replication, and application integration. Step-by-step guide with code examples an...