class Provider (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.CustomResources.Provider |
Java | software.amazon.awscdk.customresources.Provider |
Python | aws_cdk.custom_resources.Provider |
TypeScript (source) | @aws-cdk/custom-resources » Provider |
Implements
IConstruct
, IConstruct
, IDependable
, ICustom
Defines an AWS CloudFormation custom resource provider.
Example
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
});
Initializer
new Provider(scope: Construct, id: string, props: ProviderProps)
Parameters
- scope
Construct
- id
string
- props
Provider
Props
Construct Props
Name | Type | Description |
---|---|---|
on | IFunction | The AWS Lambda function to invoke for all resource lifecycle operations (CREATE/UPDATE/DELETE). |
is | IFunction | The AWS Lambda function to invoke in order to determine if the operation is complete. |
log | Retention | The number of days framework log events are kept in CloudWatch Logs. |
provider | string | Provider Lambda name. |
query | Duration | Time between calls to the isComplete handler which determines if the resource has been stabilized. |
role? | IRole | AWS Lambda execution role. |
security | ISecurity [] | Security groups to attach to the provider functions. |
total | Duration | Total timeout for the entire operation. |
vpc? | IVpc | The vpc to provision the lambda functions in. |
vpc | Subnet | Which subnets from the VPC to place the lambda functions in. |
onEventHandler
Type:
IFunction
The AWS Lambda function to invoke for all resource lifecycle operations (CREATE/UPDATE/DELETE).
This function is responsible to begin the requested resource operation
(CREATE/UPDATE/DELETE) and return any additional properties to add to the
event, which will later be passed to isComplete
. The PhysicalResourceId
property must be included in the response.
isCompleteHandler?
Type:
IFunction
(optional, default: provider is synchronous. This means that the onEvent
handler
is expected to finish all lifecycle operations within the initial invocation.)
The AWS Lambda function to invoke in order to determine if the operation is complete.
This function will be called immediately after onEvent
and then
periodically based on the configured query interval as long as it returns
false
. If the function still returns false
and the alloted timeout has
passed, the operation will fail.
logRetention?
Type:
Retention
(optional, default: logs.RetentionDays.INFINITE)
The number of days framework log events are kept in CloudWatch Logs.
When
updating this property, unsetting it doesn't remove the log retention policy.
To remove the retention policy, set the value to INFINITE
.
providerFunctionName?
Type:
string
(optional, default: CloudFormation default name from unique physical ID)
Provider Lambda name.
The provider lambda function name.
queryInterval?
Type:
Duration
(optional, default: Duration.seconds(5))
Time between calls to the isComplete
handler which determines if the resource has been stabilized.
The first isComplete
will be called immediately after handler
and then
every queryInterval
seconds, and until timeout
has been reached or until
isComplete
returns true
.
role?
Type:
IRole
(optional, default: A default role will be created.)
AWS Lambda execution role.
The role that will be assumed by the AWS Lambda. Must be assumable by the 'lambda.amazonaws.com' service principal.
securityGroups?
Type:
ISecurity
[]
(optional, default: If vpc
is not supplied, no security groups are attached. Otherwise, a dedicated security
group is created for each function.)
Security groups to attach to the provider functions.
Only used if 'vpc' is supplied
totalTimeout?
Type:
Duration
(optional, default: Duration.minutes(30))
Total timeout for the entire operation.
The maximum timeout is 2 hours (yes, it can exceed the AWS Lambda 15 minutes)
vpc?
Type:
IVpc
(optional, default: functions are not provisioned inside a vpc.)
The vpc to provision the lambda functions in.
vpcSubnets?
Type:
Subnet
(optional, default: the Vpc default strategy if not specified)
Which subnets from the VPC to place the lambda functions in.
Only used if 'vpc' is supplied. Note: internet access for Lambdas requires a NAT gateway, so picking Public subnets is not allowed.
Properties
Name | Type | Description |
---|---|---|
node | Construct | The construct tree node associated with this construct. |
on | IFunction | The user-defined AWS Lambda function which is invoked for all resource lifecycle operations (CREATE/UPDATE/DELETE). |
service | string | The service token to use in order to define custom resources that are backed by this provider. |
is | IFunction | The user-defined AWS Lambda function which is invoked asynchronously in order to determine if the operation is complete. |
node
Type:
Construct
The construct tree node associated with this construct.
onEventHandler
Type:
IFunction
The user-defined AWS Lambda function which is invoked for all resource lifecycle operations (CREATE/UPDATE/DELETE).
serviceToken
Type:
string
The service token to use in order to define custom resources that are backed by this provider.
isCompleteHandler?
Type:
IFunction
(optional)
The user-defined AWS Lambda function which is invoked asynchronously in order to determine if the operation is complete.
Methods
Name | Description |
---|---|
bind(_scope) | Called by CustomResource which uses this provider. |
to | Returns a string representation of this construct. |
bind(_scope)
public bind(_scope: Construct): CustomResourceProviderConfig
⚠️ Deprecated: use provider.serviceToken
instead
Parameters
- _scope
Construct
Returns
Called by CustomResource
which uses this provider.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.