java.lang.Object
software.amazon.jsii.JsiiObject
All Implemented Interfaces:
IConstruct, IDependable, IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:40.432Z") @Stability(Stable) public class CfnCanary extends CfnResource implements IInspectable
A CloudFormation AWS::Synthetics::Canary.

Creates or updates a canary. Canaries are scripts that monitor your endpoints and APIs from the outside-in. Canaries help you check the availability and latency of your web services and troubleshoot anomalies by investigating load time data, screenshots of the UI, logs, and metrics. You can set up a canary to run continuously or just once.

To create canaries, you must have the CloudWatchSyntheticsFullAccess policy. If you are creating a new IAM role for the canary, you also need the the iam:CreateRole , iam:CreatePolicy and iam:AttachRolePolicy permissions. For more information, see Necessary Roles and Permissions .

Do not include secrets or proprietary information in your canary names. The canary name makes up part of the Amazon Resource Name (ARN) for the canary, and the ARN is included in outbound calls over the internet. For more information, see Security Considerations for Synthetics Canaries .

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.synthetics.*;
 CfnCanary cfnCanary = CfnCanary.Builder.create(this, "MyCfnCanary")
         .artifactS3Location("artifactS3Location")
         .code(CodeProperty.builder()
                 .handler("handler")
                 // the properties below are optional
                 .s3Bucket("s3Bucket")
                 .s3Key("s3Key")
                 .s3ObjectVersion("s3ObjectVersion")
                 .script("script")
                 .sourceLocationArn("sourceLocationArn")
                 .build())
         .executionRoleArn("executionRoleArn")
         .name("name")
         .runtimeVersion("runtimeVersion")
         .schedule(ScheduleProperty.builder()
                 .expression("expression")
                 // the properties below are optional
                 .durationInSeconds("durationInSeconds")
                 .build())
         // the properties below are optional
         .artifactConfig(ArtifactConfigProperty.builder()
                 .s3Encryption(S3EncryptionProperty.builder()
                         .encryptionMode("encryptionMode")
                         .kmsKeyArn("kmsKeyArn")
                         .build())
                 .build())
         .deleteLambdaResourcesOnCanaryDeletion(false)
         .failureRetentionPeriod(123)
         .runConfig(RunConfigProperty.builder()
                 .activeTracing(false)
                 .environmentVariables(Map.of(
                         "environmentVariablesKey", "environmentVariables"))
                 .memoryInMb(123)
                 .timeoutInSeconds(123)
                 .build())
         .startCanaryAfterCreation(false)
         .successRetentionPeriod(123)
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .visualReference(VisualReferenceProperty.builder()
                 .baseCanaryRunId("baseCanaryRunId")
                 // the properties below are optional
                 .baseScreenshots(List.of(BaseScreenshotProperty.builder()
                         .screenshotName("screenshotName")
                         // the properties below are optional
                         .ignoreCoordinates(List.of("ignoreCoordinates"))
                         .build()))
                 .build())
         .vpcConfig(VPCConfigProperty.builder()
                 .securityGroupIds(List.of("securityGroupIds"))
                 .subnetIds(List.of("subnetIds"))
                 // the properties below are optional
                 .vpcId("vpcId")
                 .build())
         .build();
 
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnCanary

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

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

      @Stability(Stable) public CfnCanary(@NotNull Construct scope, @NotNull String id, @NotNull CfnCanaryProps props)
      Create a new AWS::Synthetics::Canary.

      Parameters:
      scope -
      • scope in which this resource is defined.
      This parameter is required.
      id -
      • scoped id of the resource.
      This parameter is required.
      props -
      • resource properties.
      This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector -
      • tree inspector to collect and process attributes.
      This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrCodeSourceLocationArn

      @Stability(Stable) @NotNull public String getAttrCodeSourceLocationArn()
      Ref returns the ARN of the Lambda layer where Synthetics stores the canary script code.
    • getAttrId

      @Stability(Stable) @NotNull public String getAttrId()
      The ID of the canary.
    • getAttrState

      @Stability(Stable) @NotNull public String getAttrState()
      The state of the canary.

      For example, RUNNING .

    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      The list of key-value pairs that are associated with the canary.
    • getArtifactS3Location

      @Stability(Stable) @NotNull public String getArtifactS3Location()
      The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.

      Artifacts include the log file, screenshots, and HAR files. Specify the full location path, including s3:// at the beginning of the path.

    • setArtifactS3Location

      @Stability(Stable) public void setArtifactS3Location(@NotNull String value)
      The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.

      Artifacts include the log file, screenshots, and HAR files. Specify the full location path, including s3:// at the beginning of the path.

    • getCode

      @Stability(Stable) @NotNull public Object getCode()
      Use this structure to input your script code for the canary.

      This structure contains the Lambda handler with the location where the canary should start running the script. If the script is stored in an S3 bucket, the bucket name, key, and version are also included. If the script is passed into the canary directly, the script code is contained in the value of Script .

    • setCode

      @Stability(Stable) public void setCode(@NotNull CfnCanary.CodeProperty value)
      Use this structure to input your script code for the canary.

      This structure contains the Lambda handler with the location where the canary should start running the script. If the script is stored in an S3 bucket, the bucket name, key, and version are also included. If the script is passed into the canary directly, the script code is contained in the value of Script .

    • setCode

      @Stability(Stable) public void setCode(@NotNull IResolvable value)
      Use this structure to input your script code for the canary.

      This structure contains the Lambda handler with the location where the canary should start running the script. If the script is stored in an S3 bucket, the bucket name, key, and version are also included. If the script is passed into the canary directly, the script code is contained in the value of Script .

    • getExecutionRoleArn

      @Stability(Stable) @NotNull public String getExecutionRoleArn()
      The ARN of the IAM role to be used to run the canary.

      This role must already exist, and must include lambda.amazonaws.com as a principal in the trust policy. The role must also have the following permissions:

      • s3:PutObject
      • s3:GetBucketLocation
      • s3:ListAllMyBuckets
      • cloudwatch:PutMetricData
      • logs:CreateLogGroup
      • logs:CreateLogStream
      • logs:PutLogEvents
    • setExecutionRoleArn

      @Stability(Stable) public void setExecutionRoleArn(@NotNull String value)
      The ARN of the IAM role to be used to run the canary.

      This role must already exist, and must include lambda.amazonaws.com as a principal in the trust policy. The role must also have the following permissions:

      • s3:PutObject
      • s3:GetBucketLocation
      • s3:ListAllMyBuckets
      • cloudwatch:PutMetricData
      • logs:CreateLogGroup
      • logs:CreateLogStream
      • logs:PutLogEvents
    • getName

      @Stability(Stable) @NotNull public String getName()
      The name for this canary.

      Be sure to give it a descriptive name that distinguishes it from other canaries in your account.

      Do not include secrets or proprietary information in your canary names. The canary name makes up part of the canary ARN, and the ARN is included in outbound calls over the internet. For more information, see Security Considerations for Synthetics Canaries .

    • setName

      @Stability(Stable) public void setName(@NotNull String value)
      The name for this canary.

      Be sure to give it a descriptive name that distinguishes it from other canaries in your account.

      Do not include secrets or proprietary information in your canary names. The canary name makes up part of the canary ARN, and the ARN is included in outbound calls over the internet. For more information, see Security Considerations for Synthetics Canaries .

    • getRuntimeVersion

      @Stability(Stable) @NotNull public String getRuntimeVersion()
      Specifies the runtime version to use for the canary.

      For more information about runtime versions, see Canary Runtime Versions .

    • setRuntimeVersion

      @Stability(Stable) public void setRuntimeVersion(@NotNull String value)
      Specifies the runtime version to use for the canary.

      For more information about runtime versions, see Canary Runtime Versions .

    • getSchedule

      @Stability(Stable) @NotNull public Object getSchedule()
      A structure that contains information about how often the canary is to run, and when these runs are to stop.
    • setSchedule

      @Stability(Stable) public void setSchedule(@NotNull IResolvable value)
      A structure that contains information about how often the canary is to run, and when these runs are to stop.
    • setSchedule

      @Stability(Stable) public void setSchedule(@NotNull CfnCanary.ScheduleProperty value)
      A structure that contains information about how often the canary is to run, and when these runs are to stop.
    • getArtifactConfig

      @Stability(Stable) @Nullable public Object getArtifactConfig()
      A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.
    • setArtifactConfig

      @Stability(Stable) public void setArtifactConfig(@Nullable IResolvable value)
      A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.
    • setArtifactConfig

      @Stability(Stable) public void setArtifactConfig(@Nullable CfnCanary.ArtifactConfigProperty value)
      A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.
    • getDeleteLambdaResourcesOnCanaryDeletion

      @Stability(Stable) @Nullable public Object getDeleteLambdaResourcesOnCanaryDeletion()
      AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion.
    • setDeleteLambdaResourcesOnCanaryDeletion

      @Stability(Stable) public void setDeleteLambdaResourcesOnCanaryDeletion(@Nullable Boolean value)
      AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion.
    • setDeleteLambdaResourcesOnCanaryDeletion

      @Stability(Stable) public void setDeleteLambdaResourcesOnCanaryDeletion(@Nullable IResolvable value)
      AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion.
    • getFailureRetentionPeriod

      @Stability(Stable) @Nullable public Number getFailureRetentionPeriod()
      The number of days to retain data about failed runs of this canary.

      If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.

    • setFailureRetentionPeriod

      @Stability(Stable) public void setFailureRetentionPeriod(@Nullable Number value)
      The number of days to retain data about failed runs of this canary.

      If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.

    • getRunConfig

      @Stability(Stable) @Nullable public Object getRunConfig()
      A structure that contains input information for a canary run.

      If you omit this structure, the frequency of the canary is used as canary's timeout value, up to a maximum of 900 seconds.

    • setRunConfig

      @Stability(Stable) public void setRunConfig(@Nullable IResolvable value)
      A structure that contains input information for a canary run.

      If you omit this structure, the frequency of the canary is used as canary's timeout value, up to a maximum of 900 seconds.

    • setRunConfig

      @Stability(Stable) public void setRunConfig(@Nullable CfnCanary.RunConfigProperty value)
      A structure that contains input information for a canary run.

      If you omit this structure, the frequency of the canary is used as canary's timeout value, up to a maximum of 900 seconds.

    • getStartCanaryAfterCreation

      @Stability(Stable) @Nullable public Object getStartCanaryAfterCreation()
      Specify TRUE to have the canary start making runs immediately after it is created.

      A canary that you create using CloudFormation can't be used to monitor the CloudFormation stack that creates the canary or to roll back that stack if there is a failure.

    • setStartCanaryAfterCreation

      @Stability(Stable) public void setStartCanaryAfterCreation(@Nullable Boolean value)
      Specify TRUE to have the canary start making runs immediately after it is created.

      A canary that you create using CloudFormation can't be used to monitor the CloudFormation stack that creates the canary or to roll back that stack if there is a failure.

    • setStartCanaryAfterCreation

      @Stability(Stable) public void setStartCanaryAfterCreation(@Nullable IResolvable value)
      Specify TRUE to have the canary start making runs immediately after it is created.

      A canary that you create using CloudFormation can't be used to monitor the CloudFormation stack that creates the canary or to roll back that stack if there is a failure.

    • getSuccessRetentionPeriod

      @Stability(Stable) @Nullable public Number getSuccessRetentionPeriod()
      The number of days to retain data about successful runs of this canary.

      If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.

    • setSuccessRetentionPeriod

      @Stability(Stable) public void setSuccessRetentionPeriod(@Nullable Number value)
      The number of days to retain data about successful runs of this canary.

      If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.

    • getVisualReference

      @Stability(Stable) @Nullable public Object getVisualReference()
      If this canary performs visual monitoring by comparing screenshots, this structure contains the ID of the canary run to use as the baseline for screenshots, and the coordinates of any parts of the screen to ignore during the visual monitoring comparison.
    • setVisualReference

      @Stability(Stable) public void setVisualReference(@Nullable IResolvable value)
      If this canary performs visual monitoring by comparing screenshots, this structure contains the ID of the canary run to use as the baseline for screenshots, and the coordinates of any parts of the screen to ignore during the visual monitoring comparison.
    • setVisualReference

      @Stability(Stable) public void setVisualReference(@Nullable CfnCanary.VisualReferenceProperty value)
      If this canary performs visual monitoring by comparing screenshots, this structure contains the ID of the canary run to use as the baseline for screenshots, and the coordinates of any parts of the screen to ignore during the visual monitoring comparison.
    • getVpcConfig

      @Stability(Stable) @Nullable public Object getVpcConfig()
      If this canary is to test an endpoint in a VPC, this structure contains information about the subnet and security groups of the VPC endpoint.

      For more information, see Running a Canary in a VPC .

    • setVpcConfig

      @Stability(Stable) public void setVpcConfig(@Nullable IResolvable value)
      If this canary is to test an endpoint in a VPC, this structure contains information about the subnet and security groups of the VPC endpoint.

      For more information, see Running a Canary in a VPC .

    • setVpcConfig

      @Stability(Stable) public void setVpcConfig(@Nullable CfnCanary.VPCConfigProperty value)
      If this canary is to test an endpoint in a VPC, this structure contains information about the subnet and security groups of the VPC endpoint.

      For more information, see Running a Canary in a VPC .