Provides a Synthetics Canary resource.
resource "aws_synthetics_canary" "some" {
name = "some-canary"
artifact_s3_location = "s3://some-bucket/"
execution_role_arn = "some-role"
handler = "exports.handler"
zip_file = "test-fixtures/lambdatest.zip"
runtime_version = "syn-1.0"
schedule {
expression = "rate(0 minute)"
}
}
The following arguments are required:
artifact_s3_location
- (Required) Location in Amazon S3 where Synthetics stores artifacts from the test runs of this canary.execution_role_arn
- (Required) ARN of the IAM role to be used to run the canary. see AWS Docs for permissions needs for IAM Role.handler
- (Required) Entry point to use for the source code when running the canary. This value must end with the string .handler
.name
- (Required) Name for this canary. Has a maximum length of 21 characters. Valid characters are lowercase alphanumeric, hyphen, or underscore.runtime_version
- (Required) Runtime version to use for the canary. Versions change often so consult the Amazon CloudWatch documentation for the latest valid versions. Values include syn-python-selenium-1.0
, syn-nodejs-puppeteer-3.0
, syn-nodejs-2.2
, syn-nodejs-2.1
, syn-nodejs-2.0
, and syn-1.0
.schedule
- (Required) Configuration block providing how often the canary is to run and when these test runs are to stop. Detailed below.The following arguments are optional:
delete_lambda
- (Optional) Specifies whether to also delete the Lambda functions and layers used by this canary. The default is false
.vpc_config
- (Optional) Configuration block. Detailed below.failure_retention_period
- (Optional) Number of days to retain data about failed runs of this canary. If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.run_config
- (Optional) Configuration block for individual canary runs. Detailed below.s3_bucket
- (Optional) Full bucket name which is used if your canary script is located in S3. The bucket must already exist. Conflicts with zip_file
.s3_key
- (Optional) S3 key of your script. Conflicts with zip_file
.s3_version
- (Optional) S3 version ID of your script. Conflicts with zip_file
.start_canary
- (Optional) Whether to run or stop the canary.success_retention_period
- (Optional) Number of days to retain data about successful runs of this canary. If you omit this field, the default of 31 days is used. The valid range is 1 to 455 days.tags
- (Optional) Key-value map of resource tags. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.artifact_config
- (Optional) configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3. See Artifact Config.zip_file
- (Optional) ZIP file that contains the script, if you input your canary script directly into the canary instead of referring to an S3 location. It can be up to 225KB. Conflicts with s3_bucket
, s3_key
, and s3_version
.s3_encryption
- (Optional) Configuration of the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3. See S3 Encryption.encryption_mode
- (Optional) The encryption method to use for artifacts created by this canary. Valid values are: SSE_S3
and SSE_KMS
.kms_key_arn
- (Optional) The ARN of the customer-managed KMS key to use, if you specify SSE_KMS
for encryption_mode
.expression
- (Required) Rate expression or cron expression that defines how often the canary is to run. For rate expression, the syntax is rate(number unit)
. _unit_ can be minute
, minutes
, or hour
. For cron expression, the syntax is cron(expression)
. For more information about the syntax for cron expressions, see Scheduling canary runs using cron.duration_in_seconds
- (Optional) Duration in seconds, for the canary to continue making regular runs according to the schedule in the Expression value.timeout_in_seconds
- (Optional) Number of seconds the canary is allowed to run before it must stop. If you omit this field, the frequency of the canary is used, up to a maximum of 840 (14 minutes).memory_in_mb
- (Optional) Maximum amount of memory available to the canary while it is running, in MB. The value you specify must be a multiple of 64.active_tracing
- (Optional) Whether this canary is to use active AWS X-Ray tracing when it runs. You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime.environment_variables
- (Optional) Map of environment variables that are accessible from the canary during execution. Please see AWS Docs for variables reserved for Lambda.If this canary tests an endpoint in a VPC, this structure contains information about the subnet and security groups of the VPC endpoint. For more information, see Running a Canary in a VPC.
subnet_ids
- (Required) IDs of the subnets where this canary is to run.security_group_ids
- (Required) IDs of the security groups for this canary.This resource exports the following attributes in addition to the arguments above:
arn
- Amazon Resource Name (ARN) of the Canary.engine_arn
- ARN of the Lambda function that is used as your canary's engine.id
- Name for this canary.source_location_arn
- ARN of the Lambda layer where Synthetics stores the canary script code.status
- Canary status.tags_all
- A map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.timeline
- Structure that contains information about when the canary was created, modified, and most recently run. see Timeline.vpc_id
- ID of the VPC where this canary is to run.created
- Date and time the canary was created.last_modified
- Date and time the canary was most recently modified.last_started
- Date and time that the canary's most recent run started.last_stopped
- Date and time that the canary's most recent run ended.In Terraform v1.5.0 and later, use an import
block to import Synthetics Canaries using the name
. For example:
import {
to = aws_synthetics_canary.some
id = "some-canary"
}
Using terraform import
, import Synthetics Canaries using the name
. For example:
% terraform import aws_synthetics_canary.some some-canary