Class Code
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.synthetics.Code
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
- Direct Known Subclasses:
AssetCode,InlineCode,S3Code
@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)",
date="2025-11-13T16:10:15.556Z")
@Stability(Stable)
public abstract class Code
extends software.amazon.jsii.JsiiObject
The code the canary should execute.
Example:
Canary canary = Canary.Builder.create(this, "MyCanary")
.schedule(Schedule.rate(Duration.minutes(5)))
.test(Test.custom(CustomTestOptions.builder()
.code(Code.fromAsset(join(__dirname, "canary")))
.handler("index.handler")
.build()))
.runtime(Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0)
.resourcesToReplicateTags(List.of(ResourceToReplicateTags.LAMBDA_FUNCTION))
.build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CodeConfigbind(software.constructs.Construct scope, String handler, RuntimeFamily family) Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.abstract CodeConfigbind(software.constructs.Construct scope, String handler, RuntimeFamily family, String runtimeName) Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.static AssetCodeSpecify code from a local path.static AssetCodefromAsset(String assetPath, AssetOptions options) Specify code from a local path.static S3CodefromBucket(IBucketRef bucket, String key) Specify code from an s3 bucket.static S3CodefromBucket(IBucketRef bucket, String key, String objectVersion) Specify code from an s3 bucket.static InlineCodefromInline(String code) Specify code inline.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Code
protected Code(software.amazon.jsii.JsiiObjectRef objRef) -
Code
protected Code(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Code
@Stability(Stable) protected Code()
-
-
Method Details
-
fromAsset
@Stability(Stable) @NotNull public static AssetCode fromAsset(@NotNull String assetPath, @Nullable AssetOptions options) Specify code from a local path.Path must include the folder structure
nodejs/node_modules/myCanaryFilename.js.- Parameters:
assetPath- Either a directory or a .zip file. This parameter is required.options-- Returns:
AssetCodeassociated with the specified path.- See Also:
-
fromAsset
Specify code from a local path.Path must include the folder structure
nodejs/node_modules/myCanaryFilename.js.- Parameters:
assetPath- Either a directory or a .zip file. This parameter is required.- Returns:
AssetCodeassociated with the specified path.- See Also:
-
fromBucket
@Stability(Stable) @NotNull public static S3Code fromBucket(@NotNull IBucketRef bucket, @NotNull String key, @Nullable String objectVersion) Specify code from an s3 bucket.The object in the s3 bucket must be a .zip file that contains the structure
nodejs/node_modules/myCanaryFilename.js.- Parameters:
bucket- The S3 bucket. This parameter is required.key- The object key. This parameter is required.objectVersion- Optional S3 object version.- Returns:
S3Codeassociated with the specified S3 object.- See Also:
-
fromBucket
@Stability(Stable) @NotNull public static S3Code fromBucket(@NotNull IBucketRef bucket, @NotNull String key) Specify code from an s3 bucket.The object in the s3 bucket must be a .zip file that contains the structure
nodejs/node_modules/myCanaryFilename.js.- Parameters:
bucket- The S3 bucket. This parameter is required.key- The object key. This parameter is required.- Returns:
S3Codeassociated with the specified S3 object.- See Also:
-
fromInline
Specify code inline.- Parameters:
code- The actual handler code (limited to 5MB). This parameter is required.- Returns:
InlineCodewith inline code.
-
bind
@Stability(Stable) @NotNull public abstract CodeConfig bind(@NotNull software.constructs.Construct scope, @NotNull String handler, @NotNull RuntimeFamily family, @Nullable String runtimeName) Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.- Parameters:
scope- The binding scope. This parameter is required.handler- This parameter is required.family- This parameter is required.runtimeName-- Returns:
- a bound
CodeConfig.
-
bind
@Stability(Stable) @NotNull public abstract CodeConfig bind(@NotNull software.constructs.Construct scope, @NotNull String handler, @NotNull RuntimeFamily family) Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.- Parameters:
scope- The binding scope. This parameter is required.handler- This parameter is required.family- This parameter is required.- Returns:
- a bound
CodeConfig.
-