Skip to content

Commit

Permalink
feat: add input argument for cloudwatch_event_target (#63)
Browse files Browse the repository at this point in the history
* feat: add input argument for cloudwatch_event_target

Co-authored-by: Moritz Zimmer <[email protected]>
Co-authored-by: Moritz Zimmer <[email protected]>
  • Loading branch information
3 people committed Sep 29, 2022
1 parent f195d88 commit 85f3f55
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions cloudwatch_event_rules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion docs/deployment/part2.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9 |

## Modules

Expand All @@ -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 |
Expand Down
3 changes: 3 additions & 0 deletions docs/part1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 4 additions & 1 deletion examples/with-cloudwatch-event-rules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -39,4 +42,4 @@ module "lambda" {
PATTERN
}
}
}
}
3 changes: 2 additions & 1 deletion modules/deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ resource "aws_s3_bucket_object" "source" {

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9 |

## Modules

Expand All @@ -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 |
Expand Down

0 comments on commit 85f3f55

Please sign in to comment.