Terraform aws resource: aws synthetics canary

From wikieduonline
Revision as of 13:50, 11 March 2024 by Welcome (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Official example[edit]

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)"
 }
}


resource "aws_synthetics_canary" "registry_access" {
  name                 = "reg_${join("-", slice(split("-", var.cluster-name), 2, 3))}_${substr(var.cluster-name, -2, -1)}"
  artifact_s3_location = "s3://${aws_s3_bucket.synthetics_canary_registry_access_artifacts.id}/"
  execution_role_arn   = aws_iam_role.canary_role.arn
  handler              = "registryAccess.handler"
  runtime_version      = "syn-nodejs-puppeteer-6.2"
  zip_file             = data.archive_file.generate_zip_registry_access.output_path

  start_canary = true
  schedule {
    expression = "rate(10 minutes)"
}
  vpc_config {
    subnet_ids         = compact([var.subnet-az-b, var.subnet-az-a])
    security_group_ids = var.node_security_groups
  }
  # Additional canary configuration
  depends_on = [
    aws_s3_bucket.synthetics_canary_registry_access_artifacts,
    data.archive_file.generate_zip_registry_access,
    aws_iam_role.canary_role,
    aws_iam_role_policy_attachment.canary_cloudwatch_policy_attachment,
    aws_iam_role_policy_attachment.canary_lambda_secret_policy_attachment,
    aws_iam_role_policy_attachment.canary_VPC_policy_attachment,
    aws_iam_role_policy_attachment.canary_lambda_policy_attachment,
    aws_iam_role_policy_attachment.node_group_role
  ]
}

Related[edit]

Errors[edit]

See also[edit]

Advertising: