From 85f3f55e62c9019c85a222b1f1f5ac1b00b667b9 Mon Sep 17 00:00:00 2001 From: Alexander Blotny Date: Thu, 29 Sep 2022 10:41:13 +0200 Subject: [PATCH] feat: add input argument for cloudwatch_event_target (#63) * feat: add input argument for cloudwatch_event_target Co-authored-by: Moritz Zimmer Co-authored-by: Moritz Zimmer --- README.md | 3 +++ cloudwatch_event_rules.tf | 5 +++-- docs/deployment/part2.md | 3 ++- docs/part1.md | 3 +++ examples/with-cloudwatch-event-rules/main.tf | 5 ++++- modules/deployment/README.md | 3 ++- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index be294d2..84244e7 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ module "lambda" { // optionally overwrite `cloudwatch_event_target_arn` in case an alias should be used for the event rule cloudwatch_event_target_arn = aws_lambda_alias.example.arn + + // optionally add `cloudwatch_event_target_input` for event input + cloudwatch_event_target_input = jsonencode({"key": "value"}) } pattern = { diff --git a/cloudwatch_event_rules.tf b/cloudwatch_event_rules.tf index b6497e5..f75cb01 100644 --- a/cloudwatch_event_rules.tf +++ b/cloudwatch_event_rules.tf @@ -25,6 +25,7 @@ resource "aws_cloudwatch_event_rule" "lambda" { resource "aws_cloudwatch_event_target" "lambda" { for_each = var.cloudwatch_event_rules - arn = lookup(each.value, "cloudwatch_event_target_arn", local.function_arn) - rule = aws_cloudwatch_event_rule.lambda[each.key].name + arn = lookup(each.value, "cloudwatch_event_target_arn", local.function_arn) + rule = aws_cloudwatch_event_rule.lambda[each.key].name + input = lookup(each.value, "cloudwatch_event_target_input", null) } diff --git a/docs/deployment/part2.md b/docs/deployment/part2.md index cbdebe9..e7291e9 100644 --- a/docs/deployment/part2.md +++ b/docs/deployment/part2.md @@ -9,7 +9,7 @@ | Name | Version | |------|---------| -| [aws](#provider\_aws) | 3.67.0 | +| [aws](#provider\_aws) | >= 4.9 | ## Modules @@ -36,6 +36,7 @@ No modules. | [aws_iam_role.trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | [aws_iam_role_policy_attachment.codedeploy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | [aws_s3_bucket.pipeline](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | +| [aws_s3_bucket_acl.pipeline](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource | | [aws_s3_bucket_policy.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | | [aws_s3_bucket_public_access_block.source](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [aws_sns_topic.notifications](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource | diff --git a/docs/part1.md b/docs/part1.md index 36cdaba..e41a5dc 100644 --- a/docs/part1.md +++ b/docs/part1.md @@ -92,6 +92,9 @@ module "lambda" { // optionally overwrite `cloudwatch_event_target_arn` in case an alias should be used for the event rule cloudwatch_event_target_arn = aws_lambda_alias.example.arn + + // optionally add `cloudwatch_event_target_input` for event input + cloudwatch_event_target_input = jsonencode({"key": "value"}) } pattern = { diff --git a/examples/with-cloudwatch-event-rules/main.tf b/examples/with-cloudwatch-event-rules/main.tf index 06c67a9..cfc93ca 100644 --- a/examples/with-cloudwatch-event-rules/main.tf +++ b/examples/with-cloudwatch-event-rules/main.tf @@ -27,6 +27,9 @@ module "lambda" { // optionally overwrite `cloudwatch_event_target_arn` in case an alias should be used for the event rule cloudwatch_event_target_arn = aws_lambda_alias.example.arn + + // optionally add `cloudwatch_event_target_input` for event input + cloudwatch_event_target_input = jsonencode({ "key" : "value" }) } pattern = { @@ -39,4 +42,4 @@ module "lambda" { PATTERN } } -} \ No newline at end of file +} diff --git a/modules/deployment/README.md b/modules/deployment/README.md index 45bf2d1..dc63b1c 100644 --- a/modules/deployment/README.md +++ b/modules/deployment/README.md @@ -173,7 +173,7 @@ resource "aws_s3_bucket_object" "source" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 3.67.0 | +| [aws](#provider\_aws) | >= 4.9 | ## Modules @@ -200,6 +200,7 @@ No modules. | [aws_iam_role.trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | [aws_iam_role_policy_attachment.codedeploy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | | [aws_s3_bucket.pipeline](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | +| [aws_s3_bucket_acl.pipeline](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource | | [aws_s3_bucket_policy.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | | [aws_s3_bucket_public_access_block.source](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [aws_sns_topic.notifications](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |