AwsSdkCall

class aws_cdk.custom_resources.AwsSdkCall(*, action, service, api_version=None, assumed_role_arn=None, ignore_error_codes_matching=None, output_path=None, output_paths=None, parameters=None, physical_resource_id=None, region=None)

Bases: object

An AWS SDK call.

Parameters:
  • action (str) – The service action to call.

  • service (str) – The service to call.

  • api_version (Optional[str]) – API version to use for the service. Default: - use latest available API version

  • assumed_role_arn (Optional[str]) – Used for running the SDK calls in underlying lambda with a different role Can be used primarily for cross-account requests to for example connect hostedzone with a shared vpc. Example for Route53 / associateVPCWithHostedZone Default: - run without assuming role

  • ignore_error_codes_matching (Optional[str]) – The regex pattern to use to catch API errors. The code property of the Error object will be tested against this pattern. If there is a match an error will not be thrown. Default: - do not catch errors

  • output_path (Optional[str]) – (deprecated) Restrict the data returned by the custom resource to a specific path in the API response. Use this to limit the data returned by the custom resource if working with API calls that could potentially result in custom response objects exceeding the hard limit of 4096 bytes. Example for ECS / updateService: ‘service.deploymentConfiguration.maximumPercent’ Default: - return all data

  • output_paths (Optional[Sequence[str]]) – Restrict the data returned by the custom resource to specific paths in the API response. Use this to limit the data returned by the custom resource if working with API calls that could potentially result in custom response objects exceeding the hard limit of 4096 bytes. Example for ECS / updateService: [‘service.deploymentConfiguration.maximumPercent’] Default: - return all data

  • parameters (Optional[Any]) – The parameters for the service action. Default: - no parameters

  • physical_resource_id (Optional[PhysicalResourceId]) – The physical resource id of the custom resource for this call. Mandatory for onCreate or onUpdate calls. Default: - no physical resource id

  • region (Optional[str]) – The region to send service requests to. Note: Cross-region operations are generally considered an anti-pattern. Consider first deploying a stack in that region. Default: - the region where this custom resource is deployed

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

action

The service action to call.

See:

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

api_version

API version to use for the service.

Default:
  • use latest available API version

See:

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/locking-api-versions.html

assumed_role_arn

Used for running the SDK calls in underlying lambda with a different role Can be used primarily for cross-account requests to for example connect hostedzone with a shared vpc.

Example for Route53 / associateVPCWithHostedZone

Default:
  • run without assuming role

ignore_error_codes_matching

The regex pattern to use to catch API errors.

The code property of the Error object will be tested against this pattern. If there is a match an error will not be thrown.

Default:
  • do not catch errors

output_path

(deprecated) Restrict the data returned by the custom resource to a specific path in the API response.

Use this to limit the data returned by the custom resource if working with API calls that could potentially result in custom response objects exceeding the hard limit of 4096 bytes.

Example for ECS / updateService: ‘service.deploymentConfiguration.maximumPercent’

Default:
  • return all data

Deprecated:

use outputPaths instead

Stability:

deprecated

output_paths

Restrict the data returned by the custom resource to specific paths in the API response.

Use this to limit the data returned by the custom resource if working with API calls that could potentially result in custom response objects exceeding the hard limit of 4096 bytes.

Example for ECS / updateService: [‘service.deploymentConfiguration.maximumPercent’]

Default:
  • return all data

parameters

The parameters for the service action.

Default:
  • no parameters

See:

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

physical_resource_id

The physical resource id of the custom resource for this call.

Mandatory for onCreate or onUpdate calls.

Default:
  • no physical resource id

region

The region to send service requests to.

Note: Cross-region operations are generally considered an anti-pattern. Consider first deploying a stack in that region.

Default:
  • the region where this custom resource is deployed

service

The service to call.

See:

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