我通过地形创造了一只金丝雀。我现在正试图通过terraform更新金丝雀脚本。我把我的剧本直接输入金丝雀。我已经包含了一个带有触发器的空资源,它总是重新创建我的zip文件。我的金丝雀脚本/ lambda层没有更新。我想知道如何触发更新来使用新的脚本版本?到目前为止,我发现唯一起作用的是地形破坏/应用。
我知道cli更新-金丝雀命令和s3选项。理想情况下,我想继续把我的剧本直接输入金丝雀。
resource "null_resource" "script-zip" {
provisioner "local-exec" {
command = <<EOT
zip -r ./recordedScript.zip nodejs/node_modules/
EOT
working_dir = path.module
}
triggers = {
always_run = "${timestamp()}"
}
}
resource "aws_synthetics_canary" "canary" {
name = var.synthetic-name
artifact_s3_location = "s3://${aws_s3_bucket.synthetics-bucket.id}"
execution_role_arn = aws_iam_role.synthetics_role.arn
handler = var.handler
zip_file = "${path.module}/recordedScript.zip"
runtime_version = var.runtime-version
start_canary = var.start-canary
depends_on = [
resource.null_resource.script-zip
]发布于 2022-10-12 14:22:49
aws_synthetics_canary资源似乎没有查看创建的zip文件的散列。我能够通过给zip文件一个唯一的名称来解决这个问题。
locals {
NOW = "${timestamp()}"
}
resource "null_resource" "script-zip" {
provisioner "local-exec" {
command = <<EOT
zip -r ./${local.NOW}-recordedScript.zip nodejs/node_modules/
EOT
working_dir = path.module
}
triggers = {
always_run = "${timestamp()}"
}
}
resource "aws_synthetics_canary" "canary" {
name = var.synthetic-name
artifact_s3_location = "s3://${aws_s3_bucket.synthetics-bucket.id}"
execution_role_arn = aws_iam_role.synthetics_role.arn
handler = var.handler
zip_file = "${path.module}/${local.NOW}-recordedScript.zip"
runtime_version = var.runtime-version
start_canary = var.start-canary
depends_on = [
resource.null_resource.script-zip
]
schedule {
expression = var.schedule
}
run_config {
environment_variables = var.env-vars
timeout_in_seconds = var.timeout
}
}https://stackoverflow.com/questions/74032476
复制相似问题