Provider

class aws_cdk.custom_resources.Provider(scope, id, *, on_event_handler, is_complete_handler=None, log_retention=None, provider_function_name=None, query_interval=None, role=None, security_groups=None, total_timeout=None, vpc=None, vpc_subnets=None)

Bases: Construct

Defines an AWS CloudFormation custom resource provider.

ExampleMetadata:

infused

Example:

import aws_cdk.custom_resources as custom_resources
import aws_cdk.aws_lambda as lambda_
from aws_cdk.core import Stack
# my_on_event_lambda: lambda.Function
# my_is_complete_lambda: lambda.Function
stack = Stack()

provider = custom_resources.Provider(stack, "myProvider",
    on_event_handler=my_on_event_lambda,
    is_complete_handler=my_is_complete_lambda
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • on_event_handler (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.

  • is_complete_handler (Optional[IFunction]) – 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. Default: - provider is synchronous. This means that the onEvent handler is expected to finish all lifecycle operations within the initial invocation.

  • log_retention (Optional[RetentionDays]) – 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. Default: logs.RetentionDays.INFINITE

  • provider_function_name (Optional[str]) – Provider Lambda name. The provider lambda function name. Default: - CloudFormation default name from unique physical ID

  • query_interval (Optional[Duration]) – 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. Default: Duration.seconds(5)

  • role (Optional[IRole]) – AWS Lambda execution role. The role that will be assumed by the AWS Lambda. Must be assumable by the ‘lambda.amazonaws.com’ service principal. Default: - A default role will be created.

  • security_groups (Optional[Sequence[ISecurityGroup]]) – Security groups to attach to the provider functions. Only used if ‘vpc’ is supplied Default: - If vpc is not supplied, no security groups are attached. Otherwise, a dedicated security group is created for each function.

  • total_timeout (Optional[Duration]) – Total timeout for the entire operation. The maximum timeout is 2 hours (yes, it can exceed the AWS Lambda 15 minutes) Default: Duration.minutes(30)

  • vpc (Optional[IVpc]) – The vpc to provision the lambda functions in. Default: - functions are not provisioned inside a vpc.

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – 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. Default: - the Vpc default strategy if not specified

Methods

bind(_scope)

(deprecated) Called by CustomResource which uses this provider.

Parameters:

_scope (Construct) –

Deprecated:

use provider.serviceToken instead

Stability:

deprecated

Return type:

CustomResourceProviderConfig

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

is_complete_handler

The user-defined AWS Lambda function which is invoked asynchronously in order to determine if the operation is complete.

node

The construct tree node associated with this construct.

on_event_handler

The user-defined AWS Lambda function which is invoked for all resource lifecycle operations (CREATE/UPDATE/DELETE).

service_token

The service token to use in order to define custom resources that are backed by this provider.

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool