AwsCustomResource

class aws_cdk.custom_resources.AwsCustomResource(scope, id, *, on_create=None, on_delete=None, on_update=None, policy_statements=None, resource_type=None, role=None, timeout=None)

Bases: aws_cdk.core.Construct

stability :stability: experimental

__init__(scope, id, *, on_create=None, on_delete=None, on_update=None, policy_statements=None, resource_type=None, role=None, timeout=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • on_create (Optional[AwsSdkCall]) – The AWS SDK call to make when the resource is created. At least onCreate, onUpdate or onDelete must be specified. Default: - the call when the resource is updated

  • on_delete (Optional[AwsSdkCall]) – The AWS SDK call to make when the resource is deleted. Default: - no call

  • on_update (Optional[AwsSdkCall]) – The AWS SDK call to make when the resource is updated. Default: - no call

  • policy_statements (Optional[List[PolicyStatement]]) – The IAM policy statements to allow the different calls. Use only if resource restriction is needed. 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. Default: - extract the permissions from the calls

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

  • role (Optional[IRole]) – The execution role for the 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 Lambda function implementing this custom resource. Default: Duration.minutes(2)

stability :stability: experimental

Return type

None

Methods

get_data(data_path)

Returns response data for the AWS SDK call.

Example for S3 / listBucket : ‘Buckets.0.Name’

Use Token.asXxx to encode the returned Reference as a specific type or use the convenience getDataString for string attributes.

Parameters

data_path (str) – the path to the data.

stability :stability: experimental

Return type

Reference

get_data_string(data_path)

Returns response data for the AWS SDK call as string.

Example for S3 / listBucket : ‘Buckets.0.Name’

Parameters

data_path (str) – the path to the data.

stability :stability: experimental

Return type

str

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

grant_principal

The principal to grant permissions to.

stability :stability: experimental

Return type

IPrincipal

node

Construct tree node which offers APIs for interacting with the construct tree.

Return type

ConstructNode

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool