canaries
Creates, updates, deletes or gets a canary resource or lists canaries in a region
Overview
| Name | canaries |
| Type | Resource |
| Description | Resource Type definition for AWS::Synthetics::Canary |
| Id | awscc.synthetics.canaries |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the canary. |
id | string | Id of the canary |
state | string | State of the canary |
code | object | Provide the canary script source |
artifact_s3_location | string | Provide the s3 bucket output location for test results |
artifact_config | object | Provide artifact configuration |
schedule | object | Frequency to run your canaries |
execution_role_arn | string | Lambda Execution role used to run your canaries |
runtime_version | string | Runtime version of Synthetics Library |
success_retention_period | integer | Retention period of successful canary runs represented in number of days |
failure_retention_period | integer | Retention period of failed canary runs represented in number of days |
tags | array | |
vpc_config | object | Provide VPC Configuration if enabled. |
run_config | object | Provide canary run configuration |
start_canary_after_creation | boolean | Runs canary if set to True. Default is False |
visual_reference | object | Visual reference configuration for visual testing |
delete_lambda_resources_on_canary_deletion | boolean | Deletes associated lambda resources created by Synthetics if set to True. Default is False |
resources_to_replicate_tags | array | List of resources which canary tags should be replicated to. |
provisioned_resource_cleanup | string | Setting to control if provisioned resources created by Synthetics are deleted alongside the canary. Default is AUTOMATIC. |
dry_run_and_update | boolean | Setting to control if UpdateCanary will perform a DryRun and validate it is PASSING before performing the Update. Default is FALSE. |
browser_configs | array | List of browser configurations for the canary |
visual_references | array | List of visual references for the canary |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the canary. |
region | string | AWS region. |
For more information, see AWS::Synthetics::Canary.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | canaries | INSERT | Name, Code, ArtifactS3Location, ExecutionRoleArn, Schedule, RuntimeVersion, region |
delete_resource | canaries | DELETE | Identifier, region |
update_resource | canaries | UPDATE | Identifier, PatchDocument, region |
list_resources | canaries_list_only | SELECT | region |
get_resource | canaries | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
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 }}';
Lists all canaries in a region.
SELECT
region,
name
FROM awscc.synthetics.canaries_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new canary resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ 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
;
/*+ create */
INSERT INTO awscc.synthetics.canaries (
Name,
Code,
ArtifactS3Location,
ArtifactConfig,
Schedule,
ExecutionRoleArn,
RuntimeVersion,
SuccessRetentionPeriod,
FailureRetentionPeriod,
Tags,
VPCConfig,
RunConfig,
StartCanaryAfterCreation,
VisualReference,
DeleteLambdaResourcesOnCanaryDeletion,
ResourcesToReplicateTags,
ProvisionedResourceCleanup,
DryRunAndUpdate,
BrowserConfigs,
VisualReferences,
region
)
SELECT
'{{ name }}',
'{{ 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 }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: canary
props:
- name: name
value: '{{ name }}'
- name: code
value:
s3_bucket: '{{ s3_bucket }}'
s3_key: '{{ s3_key }}'
s3_object_version: '{{ s3_object_version }}'
script: '{{ script }}'
handler: '{{ handler }}'
source_location_arn: '{{ source_location_arn }}'
dependencies:
- type: '{{ type }}'
reference: '{{ reference }}'
- name: artifact_s3_location
value: '{{ artifact_s3_location }}'
- name: artifact_config
value:
s3_encryption:
encryption_mode: '{{ encryption_mode }}'
kms_key_arn: '{{ kms_key_arn }}'
- name: schedule
value:
expression: '{{ expression }}'
duration_in_seconds: '{{ duration_in_seconds }}'
retry_config:
max_retries: '{{ max_retries }}'
- name: execution_role_arn
value: '{{ execution_role_arn }}'
- name: runtime_version
value: '{{ runtime_version }}'
- name: success_retention_period
value: '{{ success_retention_period }}'
- name: failure_retention_period
value: '{{ failure_retention_period }}'
- name: tags
value:
- key: '{{ key }}'
value: '{{ value }}'
- name: vpc_config
value:
vpc_id: '{{ vpc_id }}'
subnet_ids:
- '{{ subnet_ids[0] }}'
security_group_ids:
- '{{ security_group_ids[0] }}'
ipv6_allowed_for_dual_stack: '{{ ipv6_allowed_for_dual_stack }}'
- name: run_config
value:
timeout_in_seconds: '{{ timeout_in_seconds }}'
memory_in_mb: '{{ memory_in_mb }}'
ephemeral_storage: '{{ ephemeral_storage }}'
active_tracing: '{{ active_tracing }}'
environment_variables: {}
- name: start_canary_after_creation
value: '{{ start_canary_after_creation }}'
- name: visual_reference
value:
base_canary_run_id: '{{ base_canary_run_id }}'
base_screenshots:
- screenshot_name: '{{ screenshot_name }}'
ignore_coordinates:
- '{{ ignore_coordinates[0] }}'
browser_type: '{{ browser_type }}'
- name: delete_lambda_resources_on_canary_deletion
value: '{{ delete_lambda_resources_on_canary_deletion }}'
- name: resources_to_replicate_tags
value:
- '{{ resources_to_replicate_tags[0] }}'
- name: provisioned_resource_cleanup
value: '{{ provisioned_resource_cleanup }}'
- name: dry_run_and_update
value: '{{ dry_run_and_update }}'
- name: browser_configs
value:
- browser_type: null
- name: visual_references
value:
- null
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:
| Parameter | Description |
|---|---|
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:
- Create
- Update
- Read
- Delete
- List
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
synthetics:UpdateCanary,
synthetics:StartCanary,
synthetics:StartCanaryDryRun,
synthetics:StopCanary,
synthetics:GetCanary,
synthetics:GetCanaryRuns,
synthetics:TagResource,
synthetics:UntagResource,
s3:GetObject,
s3:GetObjectVersion,
s3:PutBucketEncryption,
s3:PutEncryptionConfiguration,
s3:GetBucketLocation,
lambda:AddPermission,
lambda:PublishVersion,
lambda:UpdateFunctionCode,
lambda:UpdateFunctionConfiguration,
lambda:GetFunctionConfiguration,
lambda:GetLayerVersionByArn,
lambda:GetLayerVersion,
lambda:PublishLayerVersion,
lambda:ListTags,
lambda:TagResource,
lambda:UntagResource,
iam:PassRole,
ec2:DescribeVpcs,
ec2:DescribeSubnets,
ec2:DescribeSecurityGroups
synthetics:GetCanary,
synthetics:DescribeCanaries,
synthetics:ListTagsForResource,
iam:ListRoles,
s3:ListAllMyBuckets,
s3:GetBucketLocation
synthetics:DeleteCanary,
synthetics:GetCanary,
lambda:DeleteFunction,
lambda:DeleteLayerVersion
synthetics:DescribeCanaries