Class AwsCustomResource

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.customresources.AwsCustomResource
All Implemented Interfaces:
IConstruct, IDependable, IGrantable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:42.044Z") @Stability(Stable) public class AwsCustomResource extends Construct implements IGrantable
Defines a custom resource that is materialized using specific AWS API calls.

These calls are created using a singleton Lambda function.

Use this to bridge any gap that might exist in the CloudFormation Coverage. You can specify exactly which calls are invoked for the 'CREATE', 'UPDATE' and 'DELETE' life cycle events.

Example:

 AwsCustomResource awsCustom = AwsCustomResource.Builder.create(this, "aws-custom")
         .onCreate(AwsSdkCall.builder()
                 .service("...")
                 .action("...")
                 .parameters(Map.of(
                         "text", "..."))
                 .physicalResourceId(PhysicalResourceId.of("..."))
                 .build())
         .onUpdate(AwsSdkCall.builder()
                 .service("...")
                 .action("...")
                 .parameters(Map.of(
                         "text", "...",
                         "resourceId", new PhysicalResourceIdReference()))
                 .build())
         .policy(AwsCustomResourcePolicy.fromSdkCalls(SdkCallsPolicyOptions.builder()
                 .resources(AwsCustomResourcePolicy.ANY_RESOURCE)
                 .build()))
         .build();
 
  • Constructor Details

    • AwsCustomResource

      protected AwsCustomResource(software.amazon.jsii.JsiiObjectRef objRef)
    • AwsCustomResource

      protected AwsCustomResource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • AwsCustomResource

      @Stability(Stable) public AwsCustomResource(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull AwsCustomResourceProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • getResponseField

      @Stability(Stable) @NotNull public String getResponseField(@NotNull String dataPath)
      Returns response data for the AWS SDK call as string.

      Example for S3 / listBucket : 'Buckets.0.Name'

      Note that you cannot use this method if ignoreErrorCodesMatching is configured for any of the SDK calls. This is because in such a case, the response data might not exist, and will cause a CloudFormation deploy time error.

      Parameters:
      dataPath - the path to the data. This parameter is required.
    • getResponseFieldReference

      @Stability(Stable) @NotNull public Reference getResponseFieldReference(@NotNull String dataPath)
      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.

      Note that you cannot use this method if ignoreErrorCodesMatching is configured for any of the SDK calls. This is because in such a case, the response data might not exist, and will cause a CloudFormation deploy time error.

      Parameters:
      dataPath - the path to the data. This parameter is required.
    • getGrantPrincipal

      @Stability(Stable) @NotNull public IPrincipal getGrantPrincipal()
      The principal to grant permissions to.
      Specified by:
      getGrantPrincipal in interface IGrantable