Skip to content

Instantly share code, notes, and snippets.

@ridjex
Created March 18, 2025 13:29
Show Gist options
  • Save ridjex/99988fdd6720297cd1ddc48bc6f6faf8 to your computer and use it in GitHub Desktop.
Save ridjex/99988fdd6720297cd1ddc48bc6f6faf8 to your computer and use it in GitHub Desktop.
A complete 50-line Pulumi TypeScript implementation for deploying Next.js applications to AWS Amplify with automated CI/CD pipelines. This infrastructure as code solution configures source code integration, build processes, and optional custom domain configuration while maintaining a minimal footprint. Requires only the Pulumi AWS provider and a…
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const config = new pulumi.Config();
const website = new aws.amplify.App("website", {
name: pulumi.getProject(),
repository: `https://github.com/${config.require(
"organization"
)}/${pulumi.getProject()}`,
platform: "WEB_COMPUTE",
buildSpec: `version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run build --workspace=website
artifacts:
baseDirectory: website/.next
files:
- '**/*'
cache:
paths:
- .next/cache/**/*
- node_modules/**/*
buildPath: /
appRoot: "website"`,
enableAutoBranchCreation: true,
autoBranchCreationPatterns: ["main", "feature/*"],
autoBranchCreationConfig: {
framework: "Next.js - SSR",
enableAutoBuild: true,
enablePullRequestPreview: true,
},
environmentVariables: {},
});
const main = new aws.amplify.Branch("main", {
appId: website.id,
branchName: "main",
displayName: "main",
enablePullRequestPreview: true,
framework: "Next.js - SSR",
stage: "PRODUCTION",
ttl: "5",
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment