After this lesson, you will be able to: Use the AWS CLI for common operations and write basic Infrastructure-as-Code with Terraform (and recognise CloudFormation).
Click-ops doesn't scale. IaC is what mature teams use for everything. This lesson covers the CLI + a Terraform on-ramp.
Beyond `aws configure`, these are the daily commands.
# General shape: aws <service> <verb> --optionsaws s3 lsaws ec2 describe-instancesaws ec2 describe-instances --filters 'Name=tag:Name,Values=prod' --query 'Reservations[].Instances[].InstanceId' --output textaws iam list-usersaws rds describe-db-instancesaws logs tail /aws/lambda/myfunction --follow# Profiles (multiple accounts)aws configure --profile prodAWS_PROFILE=prod aws s3 ls# Output formats--output json (default)--output text (script-friendly)--output table (human-readable)--query (JMESPath; like jq but for AWS responses)
Manual console clicks: untracked changes, no rollback, no review, lost knowledge. IaC: cloud config is YAML / HCL / TypeScript in git. Code review on changes. Rollback via git revert. Reproducible (same code, same infra). Tools: Terraform / OpenTofu (cloud-agnostic, HCL); CloudFormation (AWS-only, YAML); Pulumi / AWS CDK (real programming languages); SST / Serverless Framework (higher-level wrappers). For learning + most jobs: Terraform.
Provisions an S3 bucket. Install: brew install terraform or download from terraform.io.
# main.tfterraform {required_providers {aws = { source = "hashicorp/aws", version = "~> 5.0" }}}provider "aws" {region = "us-east-1"}resource "aws_s3_bucket" "my_bucket" {bucket = "my-bucket-${random_id.suffix.hex}"}resource "random_id" "suffix" {byte_length = 4}output "bucket_name" {value = aws_s3_bucket.my_bucket.bucket}# Workflow:terraform init # one-time, downloads providersterraform plan # shows what would changeterraform apply # applies the planterraform destroy # tears down everything
Declare DESIRED state. Tool figures out the diff vs CURRENT state. Apply the diff. State file: Terraform tracks what's been created. Store remotely (S3 + DynamoDB lock) for team use. Modules: reusable IaC packages. The Terraform Registry has thousands of community modules. Plan first, always. Never `terraform apply` without reading `plan` output. Catches the 'oh no I would have deleted the prod DB' bug.
Editing infrastructure manually after it's in IaC. Drift creeps in; next `terraform apply` reverts your manual change. No remote state. Local state files = team can't collaborate; lose laptop = lose state. No state locking. Two `terraform apply`s in parallel corrupt state. Hardcoded secrets in .tf files. Use AWS Secrets Manager + data source; never commit secrets. Skipping `plan`. The shocked face when you realise apply deleted your prod DB. Always plan.
Pick the most important reason.
Sign in and purchase access to unlock this lesson.