Class CfnCanary
- All Implemented Interfaces:
IInspectable
,ITaggable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
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.
Canaries are automated scripts that run at specified intervals against an endpoint. They include Python or Node.js code to create a Lambda function. This code needs to be packaged in a certain way, depending on the language. For more information, see Writing a canary script .
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) .provisionedResourceCleanup("provisionedResourceCleanup") .resourcesToReplicateTags(List.of("resourcesToReplicateTags")) .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 .ipv6AllowedForDualStack(false) .vpcId("vpcId") .build()) .build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier 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.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CfnCanary
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnCanary
(software.amazon.jsii.JsiiObjectRef objRef) CfnCanary
(software.constructs.Construct scope, String id, CfnCanaryProps props) -
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.Deprecated.this property has been deprecatedThe 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.Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted.To have the tags that you apply to this canary also be applied to the Lambda function that the canary uses, specify this property with the valuelambda-function
.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()
Tag Manager which manages the tags for this resource.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
Deprecated.this property has been deprecatedvoid
Deprecated.this property has been deprecatedvoid
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
Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted.void
setResourcesToReplicateTags
(List<String> value) To have the tags that you apply to this canary also be applied to the Lambda function that the canary uses, specify this property with the valuelambda-function
.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
setTagsRaw
(List<CfnTag> value) The list of key-value pairs that are associated with the 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.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
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 software.constructs.Construct scope, @NotNull String id, @NotNull CfnCanaryProps props) - Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.props
- Resource properties. This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- 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 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
Tag Manager which manages the tags for this resource. -
getArtifactS3Location
The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary. -
setArtifactS3Location
The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary. -
getCode
Use this structure to input your script code for the canary. -
setCode
Use this structure to input your script code for the canary. -
setCode
Use this structure to input your script code for the canary. -
getExecutionRoleArn
The ARN of the IAM role to be used to run the canary. -
setExecutionRoleArn
The ARN of the IAM role to be used to run the canary. -
getName
The name for this canary. -
setName
The name for this canary. -
getRuntimeVersion
Specifies the runtime version to use for the canary. -
setRuntimeVersion
Specifies the runtime version to use for the canary. -
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
@Stability(Deprecated) @Deprecated @Nullable public Object getDeleteLambdaResourcesOnCanaryDeletion()Deprecated.this property has been deprecated(deprecated) Deletes associated lambda resources created by Synthetics if set to True. -
setDeleteLambdaResourcesOnCanaryDeletion
@Stability(Deprecated) @Deprecated public void setDeleteLambdaResourcesOnCanaryDeletion(@Nullable Boolean value) Deprecated.this property has been deprecated(deprecated) Deletes associated lambda resources created by Synthetics if set to True. -
setDeleteLambdaResourcesOnCanaryDeletion
@Stability(Deprecated) @Deprecated public void setDeleteLambdaResourcesOnCanaryDeletion(@Nullable IResolvable value) Deprecated.this property has been deprecated(deprecated) Deletes associated lambda resources created by Synthetics if set to True. -
getFailureRetentionPeriod
The number of days to retain data about failed runs of this canary. -
setFailureRetentionPeriod
The number of days to retain data about failed runs of this canary. -
getProvisionedResourceCleanup
Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted. -
setProvisionedResourceCleanup
Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted. -
getResourcesToReplicateTags
To have the tags that you apply to this canary also be applied to the Lambda function that the canary uses, specify this property with the valuelambda-function
. -
setResourcesToReplicateTags
To have the tags that you apply to this canary also be applied to the Lambda function that the canary uses, specify this property with the valuelambda-function
. -
getRunConfig
A structure that contains input information for a canary run. -
setRunConfig
A structure that contains input information for a canary run. -
setRunConfig
A structure that contains input information for a canary run. -
getStartCanaryAfterCreation
Specify TRUE to have the canary start making runs immediately after it is created. -
setStartCanaryAfterCreation
Specify TRUE to have the canary start making runs immediately after it is created. -
setStartCanaryAfterCreation
Specify TRUE to have the canary start making runs immediately after it is created. -
getSuccessRetentionPeriod
The number of days to retain data about successful runs of this canary. -
setSuccessRetentionPeriod
The number of days to retain data about successful runs of this canary. -
getTagsRaw
The list of key-value pairs that are associated with the canary. -
setTagsRaw
The list of key-value pairs that are associated with the canary. -
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. -
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. -
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.
-