8000 GitHub - dominikszabo/learn-pulumi: learn-pulumi · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

About

learn-pulumi

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LearnPulumi — Portfolio IaC Project

CI License: MIT

A production-grade Pulumi Python project on AWS demonstrating ECS/Fargate + RDS Postgres with dev/staging/prod environments, WAF, CI/CD, unit testing, and policy as code.

Architecture

graph TD
    Internet -->|HTTP:80| ALB
    subgraph VPC
        ALB -->|HTTP:80| ECS["ECS Fargate (app)"]
        ECS -->|TCP:5432| RDS["RDS Postgres"]
        WAF -->|inspect| ALB
    end
    Internet --> WAF
Loading

Components:

  • VPC with public/private subnets, NAT Gateway, Flow Logs
  • ALB fronting ECS Fargate tasks
  • RDS Postgres in private subnets (encrypted at rest)
  • WAF WebACL (rate limiting + SQLi + common rules) — prod only
  • ECR repository with lifecycle policy

Prerequisites

  1. Pulumi CLI (free tier)
  2. AWS CLI configured with admin credentials
  3. Python 3.12+
  4. Docker

Bootstrap

1. Create Pulumi stacks

cd infrastructure
pulumi stack init dev
pulumi stack init staging
pulumi stack init prod

2. Set secrets

pulumi config set --secret db_password <your-password> --stack dev
pulumi config set --secret db_password <your-password> --stack staging
pulumi config set --secret db_password <your-password> --stack prod

3. Set up GitHub OIDC

Create an IAM OIDC identity provider for GitHub and an IAM role with trust policy for your repo. See AWS docs.

Update the role-to-assume ARN in .github/workflows/preview.yml and .github/workflows/deploy.yml.

Usage

# Preview changes
make preview stack=dev

# Deploy
make up stack=dev

# Run tests (no AWS credentials needed)
make test

# Validate policy
make policy

# Destroy
make destroy stack=dev

Testing

Unit tests use pulumi.runtime.test — they validate resource specifications without provisioning anything. Run with:

make test

Policy

CrossGuard policy in policies/ enforces:

  • All resources must have an Environment tag
pulumi policy apply -C policies

Why This Approach

Concern Approach
State management Pulumi Service (free tier) — no self-hosted state backend
Deployment model Fargate (serverless) — no EC2 management
CI/CD auth GitHub OIDC — no long-lived AWS keys
Secrets Pulumi encrypted config — simple, no ESC dependency
Cost control Dev/staging destroy-able; WAF only in prod

Trade-offs

  • No blue/green deployments — out of scope for v1
  • No ephemeral PR stacks — cost-prohibitive for personal AWS account
  • No integration tests — require live infra; beyond demo scope
  • NAT Gateway cost — ~$32/mo per environment; a nat-instance alternative was considered but not chosen for reliability

Cost Estimate (Monthly)

Environment Estimated Cost
Dev ~$82
Staging ~$104
Prod ~$164
All three ~$350

Costs can be reduced by destroying non-active environments.

License

MIT

About

learn-pulumi

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0