diff --git a/README.md b/README.md index c5943fd..aa93721 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Terraform module to create AWS [Lambda](https://www.terraform.io/docs/providers/ The following [event sources](https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html) are supported (see [examples](#examples)): -- [cloudwatch-scheduled-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-cloudwatch-scheduled-event): configures a [CloudWatch Event Rule](https://www.terraform.io/docs/providers/aws/r/cloudwatch_event_rule.html) to trigger the Lambda on a regular, scheduled basis +- [cloudwatch-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-cloudwatch-event): configures a [CloudWatch Event Rule](https://www.terraform.io/docs/providers/aws/r/cloudwatch_event_rule.html) to trigger the Lambda by CloudWatch [event pattern](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html) or on a regular, scheduled basis - [dynamodb](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-dynamodb-event): configures an [Event Source Mapping](https://www.terraform.io/docs/providers/aws/r/lambda_event_source_mapping.html) to trigger the Lambda by DynamoDb events - [kinesis](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-kinesis-event): configures an [Event Source Mapping](https://www.terraform.io/docs/providers/aws/r/lambda_event_source_mapping.html) to trigger the Lambda by Kinesis events - [s3](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-s3-event): configures permission to trigger the Lambda by S3 @@ -46,7 +46,7 @@ module "lambda" { // configurable event trigger, see examples event = { - type = "cloudwatch-scheduled-event" + type = "cloudwatch-event" schedule_expression = "rate(1 minute)" } @@ -74,7 +74,7 @@ module "lambda" { ### Examples -- [example-with-cloudwatch-scheduled-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-cloudwatch-scheduled-event) +- [example-with-cloudwatch-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-cloudwatch-event) - [example-with-dynamodb-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-dynamodb-event) - [example-with-kinesis-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-kinesis-event) - [example-with-s3-event](https://github.com/spring-media/terraform-aws-lambda/tree/master/examples/example-with-s3-event) diff --git a/examples/example-with-cloudwatch-scheduled-event/README.md b/examples/example-with-cloudwatch-event/README.md similarity index 73% rename from examples/example-with-cloudwatch-scheduled-event/README.md rename to examples/example-with-cloudwatch-event/README.md index c8d14be..77a08d9 100644 --- a/examples/example-with-cloudwatch-scheduled-event/README.md +++ b/examples/example-with-cloudwatch-event/README.md @@ -1,6 +1,6 @@ -# Example with CloudWatch scheduled event +# Example with CloudWatch events -Creates an AWS Lambda function triggered by a CloudWatch (scheduled) [event](https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html). +Creates AWS Lambda functions triggered by a CloudWatch [events](https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html). ## requirements diff --git a/examples/example-with-cloudwatch-event/main.tf b/examples/example-with-cloudwatch-event/main.tf new file mode 100644 index 0000000..eeb27ea --- /dev/null +++ b/examples/example-with-cloudwatch-event/main.tf @@ -0,0 +1,37 @@ +provider "aws" { + region = "eu-west-1" +} + +module "lambda-scheduled" { + source = "../../" + description = "Example AWS Lambda using go with cloudwatch scheduled event trigger" + filename = "${path.module}/test_function.zip" + function_name = "tf-example-go-basic" + handler = "example-lambda-func" + runtime = "go1.x" + + event = { + type = "cloudwatch-event" + schedule_expression = "rate(1 minute)" + } +} + +module "lambda-pattern" { + source = "../../" + description = "Example AWS Lambda using go with cloudwatch event pattern trigger" + filename = "${path.module}/test_function.zip" + function_name = "tf-example-go-basic" + handler = "example-lambda-func" + runtime = "go1.x" + + event = { + type = "cloudwatch-event" + event_pattern = <