【发布时间】:2021-03-11 14:57:07
【问题描述】:
我正在使用 Terraform 创建 AWS SQS 队列。对于每个服务,我需要创建两个队列,一个正常队列和一个错误队列。每个的设置大多相同,但我需要先创建错误队列,以便我可以将其 ARN 作为其重新驱动策略的一部分传递给正常队列。与其创建 10 个模块,不如有一种更好的方法来循环替换名称。所以编程逻辑... foreach queue_prefixes中的队列,创建错误模块,然后是常规模块。我确定我只是没有正确搜索或提出正确的问题。
沙盒/main.tf
provider "aws" {
region = "us-west-2"
}
module "hfd_sqs_error_sandbox" {
source = "../"
for_each = var.queue_prefixes
name= each.key+"_Error"
}
module "hfd_sqs_sandbox" {
source = "../"
name=hfd_sqs_error_sandbox.name
redrive_policy = jsonencode({
deadLetterTargetArn = hfd_sqs_error_sandbox_this_sqs_queue_arn,
maxReceiveCount = 3
})
}
变量.tf
variable "queue_prefixes" {
description = "Create these queues with the enviroment prefixed"
type = list(string)
default = [
"Clops",
"Document",
"Ledger",
"Log",
"Underwriting",
"Wallet",
]
}
【问题讨论】:
标签: terraform amazon-sqs terraform-provider-aws