Class CfnCanary
- All Implemented Interfaces:
IInspectable,IEnvironmentAware,ICanaryRef,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()
.blueprintTypes(List.of("blueprintTypes"))
.dependencies(List.of(DependencyProperty.builder()
.reference("reference")
// the properties below are optional
.type("type")
.build()))
.handler("handler")
.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")
.retryConfig(RetryConfigProperty.builder()
.maxRetries(123)
.build())
.build())
// the properties below are optional
.artifactConfig(ArtifactConfigProperty.builder()
.s3Encryption(S3EncryptionProperty.builder()
.encryptionMode("encryptionMode")
.kmsKeyArn("kmsKeyArn")
.build())
.build())
.browserConfigs(List.of(BrowserConfigProperty.builder()
.browserType("browserType")
.build()))
.deleteLambdaResourcesOnCanaryDeletion(false)
.dryRunAndUpdate(false)
.failureRetentionPeriod(123)
.provisionedResourceCleanup("provisionedResourceCleanup")
.resourcesToReplicateTags(List.of("resourcesToReplicateTags"))
.runConfig(RunConfigProperty.builder()
.activeTracing(false)
.environmentVariables(Map.of(
"environmentVariablesKey", "environmentVariables"))
.ephemeralStorage(123)
.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()))
.browserType("browserType")
.build())
.visualReferences(List.of(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()))
.browserType("browserType")
.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 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 interfaceA structure that specifies the browser type to use for a canary run.static final classA fluent builder forCfnCanary.static interfaceUse this structure to input your script code for the canary.static interfaceA structure that contains information about a dependency for a canary.static interfaceThe canary's retry configuration information.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.amazon.awscdk.interfaces.synthetics.ICanaryRef
ICanaryRef.Jsii$Default, ICanaryRef.Jsii$ProxyNested 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) Create a newAWS::Synthetics::Canary. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarnForCanary(ICanaryRef resource) static ICanaryReffromCanaryName(software.constructs.Construct scope, String id, String canaryName) Creates a new ICanaryRef from a canaryName.A 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.A structure that specifies the browser type to use for a canary run.A reference to a Canary resource.getCode()Use this structure to input your script code for the canary.Deprecated.this property has been deprecatedSpecifies whether to perform a dry run before updating the canary.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.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.Deprecated.this property has been deprecatedA list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on.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.static BooleanChecks whether the given object is a CfnCanary.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.voidsetBrowserConfigs(List<Object> value) A structure that specifies the browser type to use for a canary run.voidsetBrowserConfigs(IResolvable value) A structure that specifies the browser type to use for a canary run.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 deprecatedvoidsetDryRunAndUpdate(Boolean value) Specifies whether to perform a dry run before updating the canary.voidsetDryRunAndUpdate(IResolvable value) Specifies whether to perform a dry run before updating the canary.voidsetExecutionRoleArn(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.voidSpecifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted.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) Deprecated.this property has been deprecatedvoidDeprecated.this property has been deprecatedvoidsetVisualReferences(List<Object> value) A list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on.voidsetVisualReferences(IResolvable value) A list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on.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, getEnv, 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.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods 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) Create a newAWS::Synthetics::Canary.- 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
-
arnForCanary
- Parameters:
resource- This parameter is required.
-
fromCanaryName
@Stability(Stable) @NotNull public static ICanaryRef fromCanaryName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String canaryName) Creates a new ICanaryRef from a canaryName.- Parameters:
scope- This parameter is required.id- This parameter is required.canaryName- This parameter is required.
-
isCfnCanary
Checks whether the given object is a CfnCanary.- Parameters:
x- This parameter is required.
-
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. -
getCanaryRef
A reference to a Canary resource.- Specified by:
getCanaryRefin interfaceICanaryRef
-
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.Returns union: either
IResolvableorCfnCanary.CodeProperty -
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.Returns union: either
IResolvableorCfnCanary.ScheduleProperty -
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.Returns union: either
IResolvableorCfnCanary.ArtifactConfigProperty -
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. -
getBrowserConfigs
A structure that specifies the browser type to use for a canary run.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnCanary.BrowserConfigProperty> -
setBrowserConfigs
A structure that specifies the browser type to use for a canary run. -
setBrowserConfigs
A structure that specifies the browser type to use for a canary run. -
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.Returns union: either
BooleanorIResolvable -
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. -
getDryRunAndUpdate
Specifies whether to perform a dry run before updating the canary.Returns union: either
BooleanorIResolvable -
setDryRunAndUpdate
Specifies whether to perform a dry run before updating the canary. -
setDryRunAndUpdate
Specifies whether to perform a dry run before updating the canary. -
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.Returns union: either
IResolvableorCfnCanary.RunConfigProperty -
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.Returns union: either
BooleanorIResolvable -
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
Deprecated.this property has been deprecatedReturns union: eitherIResolvableorCfnCanary.VisualReferenceProperty -
setVisualReference
Deprecated.this property has been deprecated -
setVisualReference
@Stability(Deprecated) @Deprecated public void setVisualReference(@Nullable CfnCanary.VisualReferenceProperty value) Deprecated.this property has been deprecated -
getVisualReferences
A list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnCanary.VisualReferenceProperty> -
setVisualReferences
A list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on. -
setVisualReferences
A list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on. -
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.Returns union: either
IResolvableorCfnCanary.VPCConfigProperty -
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.
-