Skip to content

Commit

Permalink
fixed custom resource
Browse files Browse the repository at this point in the history
  • Loading branch information
fuu38 committed Dec 15, 2023
1 parent a1193a9 commit 0b46e67
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/candle-backend-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Construct } from 'constructs';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { DockerImage } from 'aws-cdk-lib';
import * as cr from 'aws-cdk-lib/custom-resources';

export class CandleBackendStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
Expand Down Expand Up @@ -72,11 +73,20 @@ export class CandleBackendStack extends cdk.Stack {
});
questionTable.grantWriteData(seedDataLambda)

new cdk.CustomResource(this, 'CustomResource', {
serviceToken: seedDataLambda.functionArn,
});

const dbInitiateCR = new cr.AwsCustomResource(this, 'dbInitiateCustomResource', {
onCreate: {
service:'Lambda',
action: 'invoke',
parameters: {
FunctionName: seedDataLambda.functionArn,
},
physicalResourceId: cr.PhysicalResourceId.of('dbInitiateCustomResource'),
},
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE}),
});

seedDataLambda.grantInvoke(dbInitiateCR);
const room = api.root.addResource('room');

//room:POST
Expand Down

0 comments on commit 0b46e67

Please sign in to comment.