Create FasterCreate Faster

Terraform (AWS)

Terraform scaffolding for AWS with S3 backend, per-environment configs, and common tagging.

→ Terraform Documentation

What create-faster adds

A complete infra/ directory with AWS provider configuration, S3 remote state backend, and per-environment variable files. No npm dependencies are added -- Terraform is installed separately.

Files created:

infra/
├── providers.tf              # AWS provider ~> 6.0, required_version >= 1.10, common tags
├── backend.tf                # S3 backend declaration
├── variables.tf              # project_name, env (dev/staging/prod validation)
├── variables.auto.tfvars     # Defaults pre-filled with project name
├── secrets.auto.tfvars       # Placeholder for sensitive values (gitignored)
├── outputs.tf                # Empty placeholder for resource outputs
├── main.tf                   # Empty placeholder for your resources
└── backend/
    ├── dev.hcl               # Dev environment S3 backend config
    └── prod.hcl              # Prod environment S3 backend config

providers.tf

Configures the AWS provider with:

  • AWS provider ~> 6.0
  • Terraform >= 1.10.0 (required for native state locking)
  • local.resource_name computed as {project_name}-{env}
  • local.common_tags applied to all resources via default_tags (Project, Env, ManagedBy)

backend.tf

Declares an empty S3 backend. Configuration is injected at init time via -backend-config (a partial configuration):

terraform init -backend-config=backend/dev.hcl

variables.tf

Two variables:

  • project_name -- used in resource naming and tags
  • env -- validated to dev, staging, or prod

variables.auto.tfvars

Pre-filled with the project name and env = "dev". There is no region: see Profile and region.

secrets.auto.tfvars

Empty placeholder for sensitive values. Gitignored so secrets never reach the repository.

backend/ configs

Per-environment S3 backend configs with use_lockfile = true (Terraform >= 1.10 native file locking, no DynamoDB table needed). Fill in the <BUCKET_NAME> placeholder before first use, with a bucket you created: Terraform cannot create its own state bucket.

main.tf

Empty file where you add your infrastructure resources.

.gitignore

.terraform/, .build/ (where the Lambda module of the Lambda (Terraform) blueprint writes its zips), *.tfstate*, and secrets.auto.tfvars are added to .gitignore.

Profile and region

The backend files and the provider name neither an AWS profile nor a region. Terraform reads them from the environment: the S3 backend takes AWS_PROFILE and AWS_REGION (S3 backend configuration), and so does the AWS provider (provider configuration). The same files therefore work on a laptop and in CI:

  • Locally, export AWS_PROFILE and AWS_REGION in the shell.
  • In a GitHub Actions workflow, aws-actions/configure-aws-credentials assumes an IAM role through OIDC and exports temporary credentials and AWS_REGION (its aws-region input). The workflow of the Lambda blueprint reads that region from the AWS_REGION GitHub variable.

A profile in a backend file would break CI, which has no profile.

First deploy

The generated README.md has a "Deploying to AWS (Terraform)" section, in order: the AWS credentials and region, the state bucket (aws s3 mb, with versioning), the <BUCKET_NAME> placeholder of both backend files, then terraform -chdir=infra init -backend-config=backend/dev.hcl. With the Lambda (Terraform) blueprint it continues with the build, apply, the live URL and the GitHub Actions setup.

TanStack Start on Lambda

infra/ provisions no resource for any stack, TanStack Start included. When the project has a TanStack Start app, the generated AGENTS.md documents how to run it on AWS Lambda with Nitro's aws-lambda preset:

  • Select the preset for the deploy build only (NITRO_PRESET=aws-lambda npm run build, or the bun / pnpm equivalent, run from the app directory). An aws-lambda build does not listen, so keep it out of vite.config.ts and out of the build script that start relies on.
  • Zip .output/server and set the Lambda handler to index.handler.
  • The preset does not serve .output/public: serve it from S3 behind CloudFront, or embed it with serveStatic: 'inline'.
  • A buffered Lambda response is capped at 6 MB, so inlined assets suit a starter, not large media.

To get the function, bucket and CloudFront provisioned for you, use the SST deployment instead.

NODE_ENV on Lambda

A Lambda you create never runs the app's start script. Next.js and TanStack Start builds already replace process.env.NODE_ENV with production in their server bundle. A Hono or Node app has to get it from the way you bundle it:

  • With bun build, Bun inlines process.env.NODE_ENV at build time, and a plain bun build inlines development. With PostgreSQL that compiles the generated client's TLS default to off, whatever the Lambda environment says. Build with --production (which also minifies) or with NODE_ENV=production in the build environment:

    bun build src/index.ts --target node --production --outfile dist/index.mjs
    # or, unminified
    NODE_ENV=production bun build src/index.ts --target node --outfile dist/index.mjs
  • A bundler that leaves process.env.NODE_ENV to runtime reads the function environment: set NODE_ENV=production in its environment block.

Otherwise the DATABASE_URL must set sslmode=verify-full (see PostgreSQL).

CLI usage

bunx create-faster myproject \
  --app myproject:nextjs \
  --deployment terraform-aws \
  --pm bun

Create the state bucket and fill in <BUCKET_NAME> as the README says, then initialize and plan:

export AWS_PROFILE=my-profile AWS_REGION=eu-west-3
cd infra
terraform init -backend-config=backend/dev.hcl
terraform plan

On this page