// use the provider framework from aws-cdk/custom-resources:
const provider = new customresources.Provider(this, 'ResourceProvider', {
onEventHandler,
isCompleteHandler, // optional
});
new CustomResource(this, 'MyResource', {
serviceToken: provider.serviceToken,
});
import * as custom_resources from '@aws-cdk/custom-resources';
import * as lambda from '@aws-cdk/aws-lambda';
import { Stack } from '@aws-cdk/core';
declare const myOnEventLambda: lambda.Function;
declare const myIsCompleteLambda: lambda.Function;
const stack = new Stack();
const provider = new custom_resources.Provider(stack, 'myProvider', {
onEventHandler: myOnEventLambda,
isCompleteHandler: myIsCompleteLambda, // optional
});
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cloudformation from '@aws-cdk/aws-cloudformation';
import * as cdk from '@aws-cdk/core';
declare const customResourceProvider: cloudformation.CustomResourceProvider;
declare const properties: any;
const customResource = new cloudformation.CustomResource(this, 'MyCustomResource', {
provider: customResourceProvider,
// the properties below are optional
properties: {
propertiesKey: properties,
},
removalPolicy: cdk.RemovalPolicy.DESTROY,
resourceType: 'resourceType',
});
import * as cloudformation from '@aws-cdk/aws-cloudformation';
import * as lambda from '@aws-cdk/aws-lambda';
declare const myFunction: lambda.Function;
// invoke an AWS Lambda function when a lifecycle event occurs:
const provider = cloudformation.CustomResourceProvider.fromLambda(myFunction);
import * as cloudformation from '@aws-cdk/aws-cloudformation';
import * as sns from '@aws-cdk/aws-sns';
declare const myTopic: sns.Topic;
// publish lifecycle events to an SNS topic:
const provider = cloudformation.CustomResourceProvider.fromTopic(myTopic);