@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:43.907Z") public class CfnCanary extends CfnResource implements IInspectable
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") .build()) .executionRoleArn("executionRoleArn") .name("name") .runtimeVersion("runtimeVersion") .schedule(ScheduleProperty.builder() .expression("expression") // the properties below are optional .durationInSeconds("durationInSeconds") .build()) .startCanaryAfterCreation(false) // 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()) .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();
Modifier and Type | Class and Description |
---|---|
static interface |
CfnCanary.ArtifactConfigProperty
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 |
CfnCanary.BaseScreenshotProperty
A structure representing a screenshot that is used as a baseline during visual monitoring comparisons made by the canary.
|
static class |
CfnCanary.Builder
A fluent builder for
CfnCanary . |
static interface |
CfnCanary.CodeProperty
Use this structure to input your script code for the canary.
|
static interface |
CfnCanary.RunConfigProperty
A structure that contains input information for a canary run.
|
static interface |
CfnCanary.S3EncryptionProperty
A structure that contains the configuration of the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3 .
|
static interface |
CfnCanary.ScheduleProperty
This structure specifies how often a canary is to make runs and the date and time when it should stop making runs.
|
static interface |
CfnCanary.VisualReferenceProperty
Defines the screenshots to use as the baseline for comparisons during visual monitoring comparisons during future runs of this canary.
|
static interface |
CfnCanary.VPCConfigProperty
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.
|
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
IConstruct.Jsii$Default
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
Modifier | Constructor and Description |
---|---|
|
CfnCanary(Construct scope,
java.lang.String id,
CfnCanaryProps props)
Create a new `AWS::Synthetics::Canary`.
|
protected |
CfnCanary(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnCanary(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
java.lang.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.
|
java.lang.String |
getArtifactS3Location()
The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.
|
java.lang.String |
getAttrId()
The ID of the canary.
|
java.lang.String |
getAttrState()
The state of the canary.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getCfnProperties() |
java.lang.Object |
getCode()
Use this structure to input your script code for the canary.
|
java.lang.Object |
getDeleteLambdaResourcesOnCanaryDeletion()
Specifies whether AWS CloudFormation is to also delete the Lambda functions and layers used by this canary, when the canary is deleted.
|
java.lang.String |
getExecutionRoleArn()
The ARN of the IAM role to be used to run the canary.
|
java.lang.Number |
getFailureRetentionPeriod()
The number of days to retain data about failed runs of this canary.
|
java.lang.String |
getName()
The name for this canary.
|
java.lang.Object |
getRunConfig()
A structure that contains input information for a canary run.
|
java.lang.String |
getRuntimeVersion()
Specifies the runtime version to use for the canary.
|
java.lang.Object |
getSchedule()
A structure that contains information about how often the canary is to run, and when these runs are to stop.
|
java.lang.Object |
getStartCanaryAfterCreation()
Specify TRUE to have the canary start making runs immediately after it is created.
|
java.lang.Number |
getSuccessRetentionPeriod()
The number of days to retain data about successful runs of this canary.
|
TagManager |
getTags()
The list of key-value pairs that are associated with the canary.
|
java.lang.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.
|
java.lang.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.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
renderProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
void |
setArtifactConfig(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.
|
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 |
setArtifactS3Location(java.lang.String value)
The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.
|
void |
setCode(CfnCanary.CodeProperty value)
Use this structure to input your script code for the canary.
|
void |
setCode(IResolvable value)
Use this structure to input your script code for the canary.
|
void |
setDeleteLambdaResourcesOnCanaryDeletion(java.lang.Boolean value)
Specifies whether AWS CloudFormation is to also delete the Lambda functions and layers used by this canary, when the canary is deleted.
|
void |
setDeleteLambdaResourcesOnCanaryDeletion(IResolvable value)
Specifies whether AWS CloudFormation is to also delete the Lambda functions and layers used by this canary, when the canary is deleted.
|
void |
setExecutionRoleArn(java.lang.String value)
The ARN of the IAM role to be used to run the canary.
|
void |
setFailureRetentionPeriod(java.lang.Number value)
The number of days to retain data about failed runs of this canary.
|
void |
setName(java.lang.String value)
The name for this canary.
|
void |
setRunConfig(CfnCanary.RunConfigProperty value)
A structure that contains input information for a canary run.
|
void |
setRunConfig(IResolvable value)
A structure that contains input information for a canary run.
|
void |
setRuntimeVersion(java.lang.String value)
Specifies the runtime version to use for the canary.
|
void |
setSchedule(CfnCanary.ScheduleProperty value)
A structure that contains information about how often the canary is to run, and when these runs are to stop.
|
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 |
setStartCanaryAfterCreation(java.lang.Boolean value)
Specify TRUE to have the canary start making runs immediately after it is created.
|
void |
setStartCanaryAfterCreation(IResolvable value)
Specify TRUE to have the canary start making runs immediately after it is created.
|
void |
setSuccessRetentionPeriod(java.lang.Number value)
The number of days to retain data about successful runs of this canary.
|
void |
setVisualReference(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.
|
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 |
setVpcConfig(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.
|
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.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
public static final java.lang.String CFN_RESOURCE_TYPE_NAME
protected CfnCanary(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnCanary(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnCanary(Construct scope, java.lang.String id, CfnCanaryProps props)
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.public void inspect(TreeInspector inspector)
inspect
in interface IInspectable
inspector
- - tree inspector to collect and process attributes. This parameter is required.protected java.util.Map<java.lang.String,java.lang.Object> renderProperties(java.util.Map<java.lang.String,java.lang.Object> props)
renderProperties
in class CfnResource
props
- This parameter is required.public java.lang.String getAttrId()
public java.lang.String getAttrState()
For example, RUNNING
.
protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
getCfnProperties
in class CfnResource
public TagManager getTags()
public java.lang.String getArtifactS3Location()
Artifacts include the log file, screenshots, and HAR files. Specify the full location path, including s3://
at the beginning of the path.
public void setArtifactS3Location(java.lang.String value)
Artifacts include the log file, screenshots, and HAR files. Specify the full location path, including s3://
at the beginning of the path.
public java.lang.Object getCode()
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
.
public void setCode(CfnCanary.CodeProperty value)
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
.
public void setCode(IResolvable value)
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
.
public java.lang.String getExecutionRoleArn()
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
public void setExecutionRoleArn(java.lang.String value)
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
public java.lang.String getName()
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 .
public void setName(java.lang.String value)
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 .
public java.lang.String getRuntimeVersion()
For more information about runtime versions, see Canary Runtime Versions .
public void setRuntimeVersion(java.lang.String value)
For more information about runtime versions, see Canary Runtime Versions .
public java.lang.Object getSchedule()
public void setSchedule(IResolvable value)
public void setSchedule(CfnCanary.ScheduleProperty value)
public java.lang.Object getStartCanaryAfterCreation()
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.
public void setStartCanaryAfterCreation(java.lang.Boolean value)
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.
public void setStartCanaryAfterCreation(IResolvable value)
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.
public java.lang.Object getArtifactConfig()
public void setArtifactConfig(IResolvable value)
public void setArtifactConfig(CfnCanary.ArtifactConfigProperty value)
public java.lang.Object getDeleteLambdaResourcesOnCanaryDeletion()
The default is false.
public void setDeleteLambdaResourcesOnCanaryDeletion(java.lang.Boolean value)
The default is false.
public void setDeleteLambdaResourcesOnCanaryDeletion(IResolvable value)
The default is false.
public java.lang.Number getFailureRetentionPeriod()
If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.
public void setFailureRetentionPeriod(java.lang.Number value)
If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.
public java.lang.Object getRunConfig()
If you omit this structure, the frequency of the canary is used as canary's timeout value, up to a maximum of 900 seconds.
public void setRunConfig(IResolvable value)
If you omit this structure, the frequency of the canary is used as canary's timeout value, up to a maximum of 900 seconds.
public void setRunConfig(CfnCanary.RunConfigProperty value)
If you omit this structure, the frequency of the canary is used as canary's timeout value, up to a maximum of 900 seconds.
public java.lang.Number getSuccessRetentionPeriod()
If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.
public void setSuccessRetentionPeriod(java.lang.Number value)
If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.
public java.lang.Object getVisualReference()
public void setVisualReference(IResolvable value)
public void setVisualReference(CfnCanary.VisualReferenceProperty value)
public java.lang.Object getVpcConfig()
For more information, see Running a Canary in a VPC .
public void setVpcConfig(IResolvable value)
For more information, see Running a Canary in a VPC .
public void setVpcConfig(CfnCanary.VPCConfigProperty value)
For more information, see Running a Canary in a VPC .