Class CfnCanary
Creates or updates a canary.
Inherited Members
Namespace: Amazon.CDK.AWS.Synthetics
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnCanary : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnCanary
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
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 .
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html
CloudformationResource: AWS::Synthetics::Canary
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Synthetics;
var cfnCanary = new CfnCanary(this, "MyCfnCanary", new CfnCanaryProps {
ArtifactS3Location = "artifactS3Location",
Code = new CodeProperty {
Handler = "handler",
// the properties below are optional
S3Bucket = "s3Bucket",
S3Key = "s3Key",
S3ObjectVersion = "s3ObjectVersion",
Script = "script",
SourceLocationArn = "sourceLocationArn"
},
ExecutionRoleArn = "executionRoleArn",
Name = "name",
RuntimeVersion = "runtimeVersion",
Schedule = new ScheduleProperty {
Expression = "expression",
// the properties below are optional
DurationInSeconds = "durationInSeconds"
},
// the properties below are optional
ArtifactConfig = new ArtifactConfigProperty {
S3Encryption = new S3EncryptionProperty {
EncryptionMode = "encryptionMode",
KmsKeyArn = "kmsKeyArn"
}
},
DeleteLambdaResourcesOnCanaryDeletion = false,
FailureRetentionPeriod = 123,
ProvisionedResourceCleanup = "provisionedResourceCleanup",
ResourcesToReplicateTags = new [] { "resourcesToReplicateTags" },
RunConfig = new RunConfigProperty {
ActiveTracing = false,
EnvironmentVariables = new Dictionary<string, string> {
{ "environmentVariablesKey", "environmentVariables" }
},
MemoryInMb = 123,
TimeoutInSeconds = 123
},
StartCanaryAfterCreation = false,
SuccessRetentionPeriod = 123,
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
VisualReference = new VisualReferenceProperty {
BaseCanaryRunId = "baseCanaryRunId",
// the properties below are optional
BaseScreenshots = new [] { new BaseScreenshotProperty {
ScreenshotName = "screenshotName",
// the properties below are optional
IgnoreCoordinates = new [] { "ignoreCoordinates" }
} }
},
VpcConfig = new VPCConfigProperty {
SecurityGroupIds = new [] { "securityGroupIds" },
SubnetIds = new [] { "subnetIds" },
// the properties below are optional
Ipv6AllowedForDualStack = false,
VpcId = "vpcId"
}
});
Synopsis
Constructors
CfnCanary(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnCanary(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CfnCanary(Construct, String, ICfnCanaryProps) |
Properties
ArtifactConfig | A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3. |
ArtifactS3Location | The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary. |
AttrCodeSourceLocationArn |
|
AttrId | The ID of the canary. |
AttrState | The state of the canary. |
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
Code | Use this structure to input your script code for the canary. |
DeleteLambdaResourcesOnCanaryDeletion | (deprecated) Deletes associated lambda resources created by Synthetics if set to True. |
ExecutionRoleArn | The ARN of the IAM role to be used to run the canary. |
FailureRetentionPeriod | The number of days to retain data about failed runs of this canary. |
Name | The name for this canary. |
ProvisionedResourceCleanup | Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted. |
ResourcesToReplicateTags | 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 value |
RunConfig | A structure that contains input information for a canary run. |
RuntimeVersion | Specifies the runtime version to use for the canary. |
Schedule | A structure that contains information about how often the canary is to run, and when these runs are to stop. |
StartCanaryAfterCreation | Specify TRUE to have the canary start making runs immediately after it is created. |
SuccessRetentionPeriod | The number of days to retain data about successful runs of this canary. |
Tags | Tag Manager which manages the tags for this resource. |
TagsRaw | The list of key-value pairs that are associated with the canary. |
VisualReference | 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. |
VpcConfig | 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
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
Constructors
CfnCanary(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnCanary(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnCanary(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnCanary(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CfnCanary(Construct, String, ICfnCanaryProps)
public CfnCanary(Construct scope, string id, ICfnCanaryProps props)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnCanaryProps
Resource properties.
Properties
ArtifactConfig
A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.
public virtual object ArtifactConfig { get; set; }
Property Value
System.Object
ArtifactS3Location
The location in Amazon S3 where Synthetics stores artifacts from the runs of this canary.
public virtual string ArtifactS3Location { get; set; }
Property Value
System.String
AttrCodeSourceLocationArn
Ref
returns the ARN of the Lambda layer where Synthetics stores the canary script code.
public virtual string AttrCodeSourceLocationArn { get; }
Property Value
System.String
Remarks
CloudformationAttribute: Code.SourceLocationArn
AttrId
The ID of the canary.
public virtual string AttrId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: Id
AttrState
The state of the canary.
public virtual string AttrState { get; }
Property Value
System.String
Remarks
For example, RUNNING
.
CloudformationAttribute: State
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
Code
Use this structure to input your script code for the canary.
public virtual object Code { get; set; }
Property Value
System.Object
DeleteLambdaResourcesOnCanaryDeletion
(deprecated) Deletes associated lambda resources created by Synthetics if set to True.
public virtual object DeleteLambdaResourcesOnCanaryDeletion { get; set; }
Property Value
System.Object
Remarks
Stability: Deprecated
ExecutionRoleArn
The ARN of the IAM role to be used to run the canary.
public virtual string ExecutionRoleArn { get; set; }
Property Value
System.String
FailureRetentionPeriod
The number of days to retain data about failed runs of this canary.
public virtual Nullable<double> FailureRetentionPeriod { get; set; }
Property Value
System.Nullable<System.Double>
Name
The name for this canary.
public virtual string Name { get; set; }
Property Value
System.String
ProvisionedResourceCleanup
Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted.
public virtual string ProvisionedResourceCleanup { get; set; }
Property Value
System.String
ResourcesToReplicateTags
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 value lambda-function
.
public virtual string[] ResourcesToReplicateTags { get; set; }
Property Value
System.String[]
RunConfig
A structure that contains input information for a canary run.
public virtual object RunConfig { get; set; }
Property Value
System.Object
RuntimeVersion
Specifies the runtime version to use for the canary.
public virtual string RuntimeVersion { get; set; }
Property Value
System.String
Schedule
A structure that contains information about how often the canary is to run, and when these runs are to stop.
public virtual object Schedule { get; set; }
Property Value
System.Object
StartCanaryAfterCreation
Specify TRUE to have the canary start making runs immediately after it is created.
public virtual object StartCanaryAfterCreation { get; set; }
Property Value
System.Object
SuccessRetentionPeriod
The number of days to retain data about successful runs of this canary.
public virtual Nullable<double> SuccessRetentionPeriod { get; set; }
Property Value
System.Nullable<System.Double>
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
The list of key-value pairs that are associated with the canary.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
VisualReference
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.
public virtual object VisualReference { get; set; }
Property Value
System.Object
VpcConfig
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.
public virtual object VpcConfig { get; set; }
Property Value
System.Object
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
- inspector TreeInspector
tree inspector to collect and process attributes.
RenderProperties(IDictionary<String, Object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
- props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>