AwsCustomResourceProps

class aws_cdk.custom_resources.AwsCustomResourceProps(*, policy, function_name=None, install_latest_aws_sdk=None, log_retention=None, on_create=None, on_delete=None, on_update=None, resource_type=None, role=None, timeout=None)

Bases: object

Properties for AwsCustomResource.

Note that at least onCreate, onUpdate or onDelete must be specified.

Parameters:
  • policy (AwsCustomResourcePolicy) – The policy that will be added to the execution role of the Lambda function implementing this custom resource provider. The custom resource also implements iam.IGrantable, making it possible to use the grantXxx() methods. As this custom resource uses a singleton Lambda function, it’s important to note the that function’s role will eventually accumulate the permissions/grants from all resources.

  • function_name (Optional[str]) – A name for the singleton Lambda function implementing this custom resource. The function name will remain the same after the first AwsCustomResource is created in a stack. Default: - AWS CloudFormation generates a unique physical ID and uses that ID for the function’s name. For more information, see Name Type.

  • install_latest_aws_sdk (Optional[bool]) – Whether to install the latest AWS SDK v2. Allows to use the latest API calls documented at https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html. The installation takes around 60 seconds. Default: true

  • log_retention (Optional[RetentionDays]) – The number of days log events of the singleton Lambda function implementing this custom resource are kept in CloudWatch Logs. Default: logs.RetentionDays.INFINITE

  • on_create (Union[AwsSdkCall, Dict[str, Any], None]) – The AWS SDK call to make when the resource is created. Default: - the call when the resource is updated

  • on_delete (Union[AwsSdkCall, Dict[str, Any], None]) – The AWS SDK call to make when the resource is deleted. Default: - no call

  • on_update (Union[AwsSdkCall, Dict[str, Any], None]) – The AWS SDK call to make when the resource is updated. Default: - no call

  • resource_type (Optional[str]) – Cloudformation Resource type. Default: - Custom::AWS

  • role (Optional[IRole]) – The execution role for the singleton Lambda function implementing this custom resource provider. This role will apply to all AwsCustomResource instances in the stack. The role must be assumable by the lambda.amazonaws.com service principal. Default: - a new role is created

  • timeout (Optional[Duration]) – The timeout for the singleton Lambda function implementing this custom resource. Default: Duration.minutes(2)

ExampleMetadata:

infused

Example:

aws_custom = cr.AwsCustomResource(self, "aws-custom",
    on_create=cr.AwsSdkCall(
        service="...",
        action="...",
        parameters={
            "text": "..."
        },
        physical_resource_id=cr.PhysicalResourceId.of("...")
    ),
    on_update=cr.AwsSdkCall(
        service="...",
        action="...",
        parameters={
            "text": "...",
            "resource_id": cr.PhysicalResourceIdReference()
        }
    ),
    policy=cr.AwsCustomResourcePolicy.from_sdk_calls(
        resources=cr.AwsCustomResourcePolicy.ANY_RESOURCE
    )
)

Attributes

function_name

A name for the singleton Lambda function implementing this custom resource.

The function name will remain the same after the first AwsCustomResource is created in a stack.

Default:

  • AWS CloudFormation generates a unique physical ID and uses that

ID for the function’s name. For more information, see Name Type.

install_latest_aws_sdk

//docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html.

The installation takes around 60 seconds.

Default:

true

Type:

Whether to install the latest AWS SDK v2. Allows to use the latest API calls documented at https

log_retention

The number of days log events of the singleton Lambda function implementing this custom resource are kept in CloudWatch Logs.

Default:

logs.RetentionDays.INFINITE

on_create

The AWS SDK call to make when the resource is created.

Default:
  • the call when the resource is updated

on_delete

The AWS SDK call to make when the resource is deleted.

Default:
  • no call

on_update

The AWS SDK call to make when the resource is updated.

Default:
  • no call

policy

The policy that will be added to the execution role of the Lambda function implementing this custom resource provider.

The custom resource also implements iam.IGrantable, making it possible to use the grantXxx() methods.

As this custom resource uses a singleton Lambda function, it’s important to note the that function’s role will eventually accumulate the permissions/grants from all resources.

See:

Policy.fromSdkCalls

resource_type

Cloudformation Resource type.

Default:
  • Custom::AWS

role

The execution role for the singleton Lambda function implementing this custom resource provider.

This role will apply to all AwsCustomResource instances in the stack. The role must be assumable by the lambda.amazonaws.com service principal.

Default:
  • a new role is created

timeout

The timeout for the singleton Lambda function implementing this custom resource.

Default:

Duration.minutes(2)