Tee*_*Kay 8 amazon-web-services amazon-cloudwatch terraform terraform-provider-aws
我想配置 CloudWatch Events 以使用 Terraform 将输入发送到 Lambda 函数。我使用以下脚本来执行此操作:
resource "aws_cloudwatch_event_rule" "aa-rule-event" {
count = "${var.count}"
name = "${var.application_name}-${element(var.names, count.index)}"
description = "${element(var.descriptions, count.index)}"
schedule_expression = "${element(var.cron-expressions, count.index)}"
is_enabled = "${element(var.rule-status-states, count.index)}"
}
resource "aws_cloudwatch_event_target" "aa-rule-target" {
count = "${var.count}"
rule = "${var.application_name}-${element(var.names, count.index)}"
target_id = "CloudWatchToLambda"
arn = "arn:aws:lambda:${var.aws_region}:${var.aws_account_number}:function:${var.application_name}-${element(var.target-lambda-function, count.index)}"
}
Run Code Online (Sandbox Code Playgroud)
我需要通过此 CloudWatch Event 向目标 Lambda 提供输入。我知道可以配置输入,但是如何在 Terraform 中配置它?
yda*_*coR 12
该aws_cloudwatch_event_target
资源采用一个可选input
参数,该参数可以将 JSON blob 传递到相当于调用 Lambda 函数时有效负载的目标。
resource "aws_cloudwatch_event_rule" "aa-rule-event" {
count = "${var.count}"
name = "${var.application_name}-${element(var.names, count.index)}"
description = "${element(var.descriptions, count.index)}"
schedule_expression = "${element(var.cron-expressions, count.index)}"
is_enabled = "${element(var.rule-status-states, count.index)}"
}
resource "aws_cloudwatch_event_target" "aa-rule-target" {
count = "${var.count}"
rule = "${var.application_name}-${element(var.names, count.index)}"
target_id = "CloudWatchToLambda"
arn = "arn:aws:lambda:${var.aws_region}:${var.aws_account_number}:function:${var.application_name}-${element(var.target-lambda-function, count.index)}"
input = <<JSON
{
"foo": {
"bar": [
1,
2
]
}
}
JSON
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7776 次 |
最近记录: |