AWS Terraform 为 Cloudfront 传递多个 arn function_association
AWS Terraform passing of multiple arn for Cloudfront function_association
我喜欢对 AWS CloudFront 资源执行动态 function_assocation
。我没有定义每个函数,而是做了类似下面的事情。
resource "aws_cloudfront_function" "functions" {
for_each = var.cf_lambda_functions
name = each.value.name
comment = each.value.description
runtime = each.value.runtime
publish = each.value.publish
code = each.value.code
}
对于 function_association
,我做了类似下面的事情。
dynamic "function_association" {
for_each = aws_cloudfront_function.functions
content {
event_type = "viewer-request"
function_arn = each.value.arn
}
}
这给了我一个错误:each.value cannot be used in this context
。您如何通过传递函数的多个 ARN 来做到这一点?
在动态块中不能使用 each
。相反,它应该是 function_association
在你的情况下:
dynamic "function_association" {
for_each = aws_cloudfront_function.functions
content {
event_type = "viewer-request"
function_arn = function_association.value.arn
}
}
我喜欢对 AWS CloudFront 资源执行动态 function_assocation
。我没有定义每个函数,而是做了类似下面的事情。
resource "aws_cloudfront_function" "functions" {
for_each = var.cf_lambda_functions
name = each.value.name
comment = each.value.description
runtime = each.value.runtime
publish = each.value.publish
code = each.value.code
}
对于 function_association
,我做了类似下面的事情。
dynamic "function_association" {
for_each = aws_cloudfront_function.functions
content {
event_type = "viewer-request"
function_arn = each.value.arn
}
}
这给了我一个错误:each.value cannot be used in this context
。您如何通过传递函数的多个 ARN 来做到这一点?
在动态块中不能使用 each
。相反,它应该是 function_association
在你的情况下:
dynamic "function_association" {
for_each = aws_cloudfront_function.functions
content {
event_type = "viewer-request"
function_arn = function_association.value.arn
}
}