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.
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)
.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
.vpcId("vpcId")
.build())
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3 .static interfaceA structure representing a screenshot that is used as a baseline during visual monitoring comparisons made by the canary.static final classA fluent builder forCfnCanary.static interfaceUse this structure to input your script code for the canary.static interfaceA structure that contains input information for a canary run.static interfaceA structure that contains the configuration of the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3 .static interfaceThis structure specifies how often a canary is to make runs and the date and time when it should stop making runs.static interfaceDefines the screenshots to use as the baseline for comparisons during visual monitoring comparisons during future runs of this canary.static interfaceIf 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.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnCanary(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnCanary(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.Refreturns 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.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.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidsetArtifactConfig(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.voidA structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.voidsetArtifactS3Location(String value) The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.voidsetCode(IResolvable value) Use this structure to input your script code for the canary.voidsetCode(CfnCanary.CodeProperty value) Use this structure to input your script code for the canary.voidDeprecated.this property has been deprecatedvoidDeprecated.this property has been deprecatedvoidsetExecutionRoleArn(String value) The ARN of the IAM role to be used to run the canary.voidsetFailureRetentionPeriod(Number value) The number of days to retain data about failed runs of this canary.voidThe name for this canary.voidsetResourcesToReplicateTags(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.voidsetRunConfig(IResolvable value) A structure that contains input information for a canary run.voidA structure that contains input information for a canary run.voidsetRuntimeVersion(String value) Specifies the runtime version to use for the canary.voidsetSchedule(IResolvable value) A structure that contains information about how often the canary is to run, and when these runs are to stop.voidA structure that contains information about how often the canary is to run, and when these runs are to stop.voidSpecify TRUE to have the canary start making runs immediately after it is created.voidSpecify TRUE to have the canary start making runs immediately after it is created.voidsetSuccessRetentionPeriod(Number value) The number of days to retain data about successful runs of this canary.voidsetTagsRaw(List<CfnTag> value) The list of key-value pairs that are associated with the canary.voidsetVisualReference(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.voidIf 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.voidsetVpcConfig(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.voidIf 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, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods 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, wait, wait, waitMethods 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:
inspectin 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:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrCodeSourceLocationArn
Refreturns 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:
getCfnPropertiesin 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. -
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.
-