Created
March 18, 2025 13:29
-
-
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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