Skip to main content

canaries

Creates, updates, deletes or gets a canary resource or lists canaries in a region

Overview

Namecanaries
TypeResource
DescriptionResource Type definition for AWS::Synthetics::Canary
Idawscc.synthetics.canaries

Fields

NameDatatypeDescription
namestringName of the canary.
idstringId of the canary
statestringState of the canary
codeobjectProvide the canary script source
artifact_s3_locationstringProvide the s3 bucket output location for test results
artifact_configobjectProvide artifact configuration
scheduleobjectFrequency to run your canaries
execution_role_arnstringLambda Execution role used to run your canaries
runtime_versionstringRuntime version of Synthetics Library
success_retention_periodintegerRetention period of successful canary runs represented in number of days
failure_retention_periodintegerRetention period of failed canary runs represented in number of days
tagsarray
vpc_configobjectProvide VPC Configuration if enabled.
run_configobjectProvide canary run configuration
start_canary_after_creationbooleanRuns canary if set to True. Default is False
visual_referenceobjectVisual reference configuration for visual testing
delete_lambda_resources_on_canary_deletionbooleanDeletes associated lambda resources created by Synthetics if set to True. Default is False
resources_to_replicate_tagsarrayList of resources which canary tags should be replicated to.
provisioned_resource_cleanupstringSetting to control if provisioned resources created by Synthetics are deleted alongside the canary. Default is AUTOMATIC.
dry_run_and_updatebooleanSetting to control if UpdateCanary will perform a DryRun and validate it is PASSING before performing the Update. Default is FALSE.
browser_configsarrayList of browser configurations for the canary
visual_referencesarrayList of visual references for the canary
regionstringAWS region.

For more information, see AWS::Synthetics::Canary.

Methods

NameResourceAccessible byRequired Params
create_resourcecanariesINSERTName, Code, ArtifactS3Location, ExecutionRoleArn, Schedule, RuntimeVersion, region
delete_resourcecanariesDELETEIdentifier, region
update_resourcecanariesUPDATEIdentifier, PatchDocument, region
list_resourcescanaries_list_onlySELECTregion
get_resourcecanariesSELECTIdentifier, region

SELECT examples

Gets all properties from an individual canary.

SELECT
region,
name,
id,
state,
code,
artifact_s3_location,
artifact_config,
schedule,
execution_role_arn,
runtime_version,
success_retention_period,
failure_retention_period,
tags,
vpc_config,
run_config,
start_canary_after_creation,
visual_reference,
delete_lambda_resources_on_canary_deletion,
resources_to_replicate_tags,
provisioned_resource_cleanup,
dry_run_and_update,
browser_configs,
visual_references
FROM awscc.synthetics.canaries
WHERE
region = '{{ region }}' AND
Identifier = '{{ name }}';

INSERT example

Use the following StackQL query and manifest file to create a new canary resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.synthetics.canaries (
Name,
Code,
ArtifactS3Location,
Schedule,
ExecutionRoleArn,
RuntimeVersion,
region
)
SELECT
'{{ name }}',
'{{ code }}',
'{{ artifact_s3_location }}',
'{{ schedule }}',
'{{ execution_role_arn }}',
'{{ runtime_version }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

UPDATE example

Use the following StackQL query and manifest file to update a canary resource, using stack-deploy.

/*+ update */
UPDATE awscc.synthetics.canaries
SET PatchDocument = string('{{ {
"ArtifactS3Location": artifact_s3_location,
"ArtifactConfig": artifact_config,
"Schedule": schedule,
"ExecutionRoleArn": execution_role_arn,
"RuntimeVersion": runtime_version,
"SuccessRetentionPeriod": success_retention_period,
"FailureRetentionPeriod": failure_retention_period,
"Tags": tags,
"VPCConfig": vpc_config,
"RunConfig": run_config,
"StartCanaryAfterCreation": start_canary_after_creation,
"VisualReference": visual_reference,
"DeleteLambdaResourcesOnCanaryDeletion": delete_lambda_resources_on_canary_deletion,
"ResourcesToReplicateTags": resources_to_replicate_tags,
"ProvisionedResourceCleanup": provisioned_resource_cleanup,
"DryRunAndUpdate": dry_run_and_update,
"BrowserConfigs": browser_configs,
"VisualReferences": visual_references
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ name }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.synthetics.canaries
WHERE
Identifier = '{{ name }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

To operate on the canaries resource, the following permissions are required:

synthetics:CreateCanary,
synthetics:StartCanary,
synthetics:GetCanary,
synthetics:TagResource,
s3:CreateBucket,
s3:GetObject,
s3:GetObjectVersion,
s3:PutBucketEncryption,
s3:PutEncryptionConfiguration,
s3:GetBucketLocation,
lambda:CreateFunction,
lambda:AddPermission,
lambda:PublishVersion,
lambda:UpdateFunctionCode,
lambda:UpdateFunctionConfiguration,
lambda:GetFunctionConfiguration,
lambda:GetLayerVersionByArn,
lambda:GetLayerVersion,
lambda:PublishLayerVersion,
lambda:TagResource,
ec2:DescribeVpcs,
ec2:DescribeSubnets,
ec2:DescribeSecurityGroups,
iam:PassRole