Skip to content
v2.278.0

CustomTestOptions Struct ​

Properties for specifying a test.

Example ​

ts
import * as cdk from 'aws-cdk-lib';

const canary = new synthetics.Canary(this, 'MyCanary', {
  schedule: synthetics.Schedule.rate(Duration.minutes(5)),
  test: synthetics.Test.custom({
    code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
    handler: 'index.handler',
  }),
  runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
  memory: cdk.Size.mebibytes(1024), // 1024 MiB
});
python
import aws_cdk as cdk


canary = synthetics.Canary(self, "MyCanary",
    schedule=synthetics.Schedule.rate(Duration.minutes(5)),
    test=synthetics.Test.custom(
        code=synthetics.Code.from_asset(path.join(__dirname, "canary")),
        handler="index.handler"
    ),
    runtime=synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
    memory=cdk.Size.mebibytes(1024)
)
java
import software.amazon.awscdk.*;


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_6_2)
        .memory(Size.mebibytes(1024))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;


var canary = new Canary(this, "MyCanary", new CanaryProps {
    Schedule = Schedule.Rate(Duration.Minutes(5)),
    Test = Test.Custom(new CustomTestOptions {
        Code = Code.FromAsset(Join(__dirname, "canary")),
        Handler = "index.handler"
    }),
    Runtime = Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
    Memory = Size.Mebibytes(1024)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cdk "github.com/aws/aws-cdk-go/awscdk"


canary := synthetics.NewCanary(this, jsii.String("MyCanary"), &CanaryProps{
	Schedule: synthetics.Schedule_Rate(awscdk.Duration_Minutes(jsii.Number(5))),
	Test: synthetics.Test_Custom(&CustomTestOptions{
		Code: synthetics.Code_FromAsset(path.join(__dirname, jsii.String("canary"))),
		Handler: jsii.String("index.handler"),
	}),
	Runtime: synthetics.Runtime_SYNTHETICS_NODEJS_PUPPETEER_6_2(),
	Memory: cdk.Size_Mebibytes(jsii.Number(1024)),
})

Properties ​

codeCodecodeCodecodeCodeCodeCodeCodeCode required #
The code of the canary script.
handlerstringhandlerstrhandlerStringHandlerstringHandler*string required #
The handler for the code.

Must end with .handler.