Skip to content

Commit 9f57dd8

Browse files
chxlloydBen Stickleybestickley
authored
feat!: add ability to customize runtime Dockerfile and build context, relativePathToWorkspace -> relativePathToPackage, remove NextjsRevalidation, replace NextjsInvalidation with NextjsPostDeploy, prune s3 and efs, see docs/breaking-changes.md (#106)
* feat: ability to customize compute image build context and Dockerfile * fix: custom cacheHandler * feat!: replace NextjsInvalidation with NextjsPostDeploy, add efs and s3 pruning * fix!: remove NextjsRevalidation * feat: reduce builder image size * fix!: deprecate relativePathToWorkspace, replace with relativePathToPackage * docs: turborepo example * docs: breaking changes, update examples, e2e tests * style: import order * docs: comment updates --------- Co-authored-by: Ben Stickley <stickb@amazon.com> Co-authored-by: Ben Stickley <35735118+bestickley@users.noreply.github.com>
1 parent 59acd39 commit 9f57dd8

File tree

105 files changed

+6148
-4461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+6148
-4461
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitattributes

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/cleanup-after-merge.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ env:
77

88
jobs:
99
check-if-should-run:
10-
if: github.event.pull_request.merged == true
1110
runs-on: ubuntu-latest
1211
steps:
13-
- run: echo "Workflow should run"
12+
- run: echo "Workflow should run for closed PR ${{ github.event.pull_request.number }}"
1413
cleanup-global-functions:
1514
needs: check-if-should-run
1615
runs-on: ubuntu-latest

.github/workflows/e2e-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,26 @@ jobs:
1313
# needed because we want ability to skip e2e tests sometimes via label and
1414
# on push to main we always want e2e tests to run
1515
check-if-should-run:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-24.04-arm
1717
# `github.event_name == 'push'` -> will run after merge to main
1818
# `!contains(github.event.pull_request.labels.*.name, 'skip-e2e-tests')` -> will run when PR doesn't have label: skip-e2e-tests
1919
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request_target' && !contains(github.event.pull_request.labels.*.name, 'skip-e2e-tests')) }}
2020
steps:
2121
- run: echo "Workflow should run"
2222

2323
# needed to manually approve fork PRs since they can contain malicious code
24+
# "Approve workflows to run" button does not apply to pull_request_target which
25+
# is required for fork PR to access OIDC for AWS access.
2426
wait-for-approval:
2527
needs: [check-if-should-run]
26-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-24.04-arm
2729
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork && 'manual-approval' || null }}
2830
steps:
2931
- run: echo "Workflow Approved! Starting PR Checks."
3032

3133
glbl-fns:
3234
needs: wait-for-approval
33-
runs-on: ubuntu-latest
35+
runs-on: ubuntu-24.04-arm
3436
steps:
3537
- name: Checkout PR
3638
uses: actions/checkout@v4
@@ -45,7 +47,7 @@ jobs:
4547

4648
glbl-cntnrs:
4749
needs: wait-for-approval
48-
runs-on: ubuntu-latest
50+
runs-on: ubuntu-22.04-arm
4951
steps:
5052
- name: Checkout PR
5153
uses: actions/checkout@v4
@@ -60,7 +62,7 @@ jobs:
6062

6163
rgnl-cntnrs:
6264
needs: wait-for-approval
63-
runs-on: ubuntu-latest
65+
runs-on: ubuntu-latest # run regional containers on x64 arch for thorough testing
6466
steps:
6567
- name: Checkout PR
6668
uses: actions/checkout@v4

.gitignore

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/deps.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

Lines changed: 20 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ const project = new awscdk.AwsCdkConstructLibrary({
1919
// majorVersion: 1,
2020
// prerelease: "beta",
2121
keywords: ["nextjs", "next", "next.js", "aws-cdk", "aws", "cdk"],
22-
cdkVersion: "2.186.0",
22+
cdkVersion: "2.196.0",
2323
jsiiVersion: "~5.8.7",
2424
packageManager: javascript.NodePackageManager.PNPM,
2525
pnpmVersion: "9",
2626
projenVersion: "^0.90.6",
2727
devDeps: [
2828
"@aws-crypto/sha256-js",
29-
"@aws-sdk/client-sqs",
29+
"@aws-sdk/client-cloudfront",
3030
"@aws-sdk/client-s3",
3131
"@aws-sdk/lib-storage",
3232
"@mrgrain/jsii-struct-builder",
@@ -37,7 +37,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
3737
"cdk-nag",
3838
"esbuild",
3939
"mime-types",
40-
"next", // bundled in src/nextjs-build/cache-handler.ts
40+
"next@14", // bundled in src/nextjs-build/cache-handler.ts
4141
"undici",
4242
],
4343
npmIgnoreOptions: {
@@ -58,16 +58,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
5858
awsSdkConnectionReuse: false, // doesn't exist in AWS SDK JS v3
5959
},
6060
projenCommand: "pnpm dlx projen",
61-
gitignore: [
62-
".idea",
63-
".DS_Store",
64-
"cdk.out",
65-
".env",
66-
"*.drawio.bkp",
67-
"ash_output",
68-
"examples/.dockerignore",
69-
"examples/builder.Dockerfile",
70-
],
61+
gitignore: [".idea", ".DS_Store", "*.drawio.bkp", "ash_output"],
7162
projenrcTs: true,
7263
eslintOptions: {
7364
prettier: true,
@@ -148,16 +139,11 @@ project.synth();
148139

149140
function bundle() {
150141
const target = `node${nodeVersion}`;
151-
project.bundler.addBundle("src/nextjs-build/cache-handler.ts", {
142+
project.bundler.addBundle("src/nextjs-build/cdk-nextjs-cache-handler.ts", {
152143
platform: "node",
153144
target,
154-
outfile: "../../../lib/nextjs-build/cache-handler.cjs",
155-
});
156-
project.bundler.addBundle("src/nextjs-build/add-cache-handler.ts", {
157-
platform: "node",
158-
target,
159-
outfile: "../../../lib/nextjs-build/add-cache-handler.mjs",
160-
format: "esm",
145+
outfile: "../../../lib/nextjs-build/cdk-nextjs-cache-handler.cjs",
146+
externals: ["next"],
161147
});
162148
project.bundler.addBundle("src/lambdas/assets-deployment/patch-fetch.js", {
163149
platform: "browser",
@@ -274,6 +260,25 @@ function updateGitHubWorkflows() {
274260
function generateStructs() {
275261
const getFilePath = (fileName: string) =>
276262
"src/generated-structs/" + fileName + ".ts";
263+
new ProjenStruct(project, {
264+
name: "OptionalNextjsPostDeployProps",
265+
filePath: getFilePath("OptionalNextjsPostDeployProps"),
266+
})
267+
.mixin(Struct.fromFqn("cdk-nextjs.NextjsPostDeployProps"))
268+
.omit("overrides")
269+
.allOptional();
270+
new ProjenStruct(project, {
271+
name: "OptionalPostDeployCustomResourceProperties",
272+
filePath: getFilePath("OptionalPostDeployCustomResourceProperties"),
273+
})
274+
.mixin(Struct.fromFqn("cdk-nextjs.PostDeployCustomResourceProperties"))
275+
.allOptional();
276+
new ProjenStruct(project, {
277+
name: "OptionalCustomResourceProps",
278+
filePath: getFilePath("OptionalCustomResourceProps"),
279+
})
280+
.mixin(Struct.fromFqn("aws-cdk-lib.CustomResourceProps"))
281+
.allOptional();
277282
new ProjenStruct(project, {
278283
name: "OptionalS3OriginBucketWithOACProps",
279284
filePath: getFilePath("OptionalS3OriginBucketWithOACProps"),
@@ -360,13 +365,6 @@ function generateStructs() {
360365
.mixin(Struct.fromFqn("cdk-nextjs.NextjsContainersProps"))
361366
.omit("overrides")
362367
.allOptional();
363-
new ProjenStruct(project, {
364-
name: "OptionalNextjsInvalidationProps",
365-
filePath: getFilePath("OptionalNextjsInvalidationProps"),
366-
})
367-
.mixin(Struct.fromFqn("cdk-nextjs.NextjsInvalidationProps"))
368-
.omit("overrides")
369-
.allOptional();
370368
new ProjenStruct(project, {
371369
name: "OptionalApplicationLoadBalancedTaskImageOptions",
372370
filePath: getFilePath("OptionalApplicationLoadBalancedTaskImageOptions"),

0 commit comments

Comments
 (0)