Skip to content

Not use custom-resource converter for dynamodb seeding adapter #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions examples/sst/stacks/OpenNextReferenceImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
Runtime,
} from "aws-cdk-lib/aws-lambda";
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
import { RetentionDays } from "aws-cdk-lib/aws-logs";
import { BlockPublicAccess, Bucket } from "aws-cdk-lib/aws-s3";
import { BucketDeployment, Source } from "aws-cdk-lib/aws-s3-deployment";
import { Queue } from "aws-cdk-lib/aws-sqs";
Expand All @@ -42,7 +41,11 @@ import {
RemovalPolicy,
Stack,
} from "aws-cdk-lib/core";
import { Provider } from "aws-cdk-lib/custom-resources";
import {
AwsCustomResource,
AwsCustomResourcePolicy,
PhysicalResourceId,
} from "aws-cdk-lib/custom-resources";
import { Construct } from "constructs";
import { readFileSync } from "fs";
import path from "path";
Expand Down Expand Up @@ -199,16 +202,22 @@ export class OpenNextCdkReferenceImplementation extends Construct {
],
});

const provider = new Provider(this, "RevalidationProvider", {
onEventHandler: insertFn,
logRetention: RetentionDays.ONE_DAY,
});

new CustomResource(this, "RevalidationResource", {
serviceToken: provider.serviceToken,
properties: {
version: Date.now().toString(),
new AwsCustomResource(this, "RevalidationInitResource", {
onUpdate: {
service: "Lambda",
action: "invoke",
parameters: {
FunctionName: insertFn.functionArn,
},
physicalResourceId: PhysicalResourceId.of("dynamodb-cache"),
},

policy: AwsCustomResourcePolicy.fromStatements([
new PolicyStatement({
actions: ["lambda:InvokeFunction"],
resources: [insertFn.functionArn],
}),
]),
});
}

Expand Down
5 changes: 3 additions & 2 deletions packages/open-next/src/adapters/dynamo-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ async function defaultHandler(
event: InitializationFunctionEvent,
): Promise<InitializationFunctionEvent> {
switch (event.requestType) {
case "delete":
return remove();
case "create":
case "update":
default:
return insert(event.requestType);
case "delete":
return remove();
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ async function createCacheAssets(monorepoRoot: string) {
plugins: [
openNextResolvePlugin({
overrides: {
converter: "custom-resource",
converter: "dummy",
},
}),
],
Expand Down
29 changes: 0 additions & 29 deletions packages/open-next/src/converters/custom-resource.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/open-next/src/types/open-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export type IncludedConverter =
| "edge"
| "node"
| "sqs-revalidate"
| "custom-resource"
| "dummy";

export type IncludedQueue = "sqs";
Expand Down