Class CfnCanary
- All Implemented Interfaces:
IConstruct
,IDependable
,IInspectable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
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();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3 .static interface
A structure representing a screenshot that is used as a baseline during visual monitoring comparisons made by the canary.static final class
A fluent builder forCfnCanary
.static interface
Use this structure to input your script code for the canary.static interface
A structure that contains input information for a canary run.static interface
A structure that contains the configuration of the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3 .static interface
This structure specifies how often a canary is to make runs and the date and time when it should stop making runs.static interface
Defines the screenshots to use as the baseline for comparisons during visual monitoring comparisons during future runs of this canary.static interface
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.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionA structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.Ref
returns the ARN of the Lambda layer where Synthetics stores the canary script code.The ID of the canary.The state of the canary.getCode()
Use this structure to input your script code for the canary.AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion
.The ARN of the IAM role to be used to run the canary.The number of days to retain data about failed runs of this canary.getName()
The name for this canary.A structure that contains input information for a canary run.Specifies the runtime version to use for the canary.A structure that contains information about how often the canary is to run, and when these runs are to stop.Specify TRUE to have the canary start making runs immediately after it is created.The number of days to retain data about successful runs of this canary.getTags()
The list of key-value pairs that are associated with the canary.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.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.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
setArtifactConfig
(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.void
A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.void
setArtifactS3Location
(String value) The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.void
setCode
(IResolvable value) Use this structure to input your script code for the canary.void
setCode
(CfnCanary.CodeProperty value) Use this structure to input your script code for the canary.void
AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion
.void
AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion
.void
setExecutionRoleArn
(String value) The ARN of the IAM role to be used to run the canary.void
setFailureRetentionPeriod
(Number value) The number of days to retain data about failed runs of this canary.void
The name for this canary.void
setRunConfig
(IResolvable value) A structure that contains input information for a canary run.void
A structure that contains input information for a canary run.void
setRuntimeVersion
(String value) Specifies the runtime version to use for the canary.void
setSchedule
(IResolvable value) A structure that contains information about how often the canary is to run, and when these runs are to stop.void
A structure that contains information about how often the canary is to run, and when these runs are to stop.void
Specify TRUE to have the canary start making runs immediately after it is created.void
Specify TRUE to have the canary start making runs immediately after it is created.void
setSuccessRetentionPeriod
(Number value) The number of days to retain data about successful runs of this canary.void
setVisualReference
(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.void
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.void
setVpcConfig
(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.void
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.Methods inherited from class software.amazon.awscdk.core.CfnResource
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.core.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.core.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
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 newAWS::Synthetics::Canary
.- Parameters:
scope
-- scope in which this resource is defined.
id
-- scoped id of the resource.
props
-- resource properties.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
-- tree inspector to collect and process attributes.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrCodeSourceLocationArn
Ref
returns the ARN of the Lambda layer where Synthetics stores the canary script code. -
getAttrId
The ID of the canary. -
getAttrState
The state of the canary.For example,
RUNNING
. -
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getTags
The list of key-value pairs that are associated with the canary. -
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
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
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
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
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
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
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
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
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
Specifies the runtime version to use for the canary.For more information about runtime versions, see Canary Runtime Versions .
-
setRuntimeVersion
Specifies the runtime version to use for the canary.For more information about runtime versions, see Canary Runtime Versions .
-
getSchedule
A structure that contains information about how often the canary is to run, and when these runs are to stop. -
setSchedule
A structure that contains information about how often the canary is to run, and when these runs are to stop. -
setSchedule
A structure that contains information about how often the canary is to run, and when these runs are to stop. -
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
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
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
AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion
. -
setDeleteLambdaResourcesOnCanaryDeletion
AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion
. -
setDeleteLambdaResourcesOnCanaryDeletion
@Stability(Stable) public void setDeleteLambdaResourcesOnCanaryDeletion(@Nullable IResolvable value) AWS::Synthetics::Canary.DeleteLambdaResourcesOnCanaryDeletion
. -
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 .
-