diff --git a/README.md b/README.md index 577327f..b4503eb 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Terraform AWS module for AWS Lambda -## Introduction +## Introduction This module creates an AWS lambda and all the related resources. It is a complete re-write of our internal terraform lambda module. -## Usage +## Usage Checkout [examples](./examples) on how to use this module for various trigger sources. ## Authors @@ -17,52 +17,77 @@ MIT Licensed. See LICENSE for full details. | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [cloudwatch-log-subscription](#module\_cloudwatch-log-subscription) | ./log_subscription/ | n/a | +| [sqs\_external](#module\_sqs\_external) | ./triggers/sqs_external/ | n/a | +| [triggered-by-api-gateway](#module\_triggered-by-api-gateway) | ./triggers/api_gateway/ | n/a | +| [triggered-by-cloudwatch-event-schedule](#module\_triggered-by-cloudwatch-event-schedule) | ./triggers/cloudwatch_event_schedule/ | n/a | +| [triggered-by-cloudwatch-event-trigger](#module\_triggered-by-cloudwatch-event-trigger) | ./triggers/cloudwatch_event_trigger/ | n/a | +| [triggered-by-cloudwatch-logs](#module\_triggered-by-cloudwatch-logs) | ./triggers/cloudwatch_logs/ | n/a | +| [triggered-by-cognito-idp](#module\_triggered-by-cognito-idp) | ./triggers/cognito_idp/ | n/a | +| [triggered-by-sqs](#module\_triggered-by-sqs) | ./triggers/sqs/ | n/a | +| [triggered-by-step-function](#module\_triggered-by-step-function) | ./triggers/step_function/ | n/a | +| [triggered\_by\_kinesis](#module\_triggered\_by\_kinesis) | ./triggers/kinesis/ | n/a | + +## Resources + +| Name | Type | +|------|------| +| [aws_cloudwatch_log_group.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource | +| [aws_lambda_function.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| cloudwatch\_log\_retention | Enable Cloudwatch logs retention | `number` | `90` | no | -| cloudwatch\_log\_subscription | Cloudwatch log stream configuration |
object({
enable : bool
filter_pattern : string
destination_arn : string
})
|
{
"destination_arn": "",
"enable": false,
"filter_pattern": ""
}
| no | -| description | Lambda function description | `string` | `"Managed by Terraform"` | no | -| environment | Lambda environment variables | `map(string)` | `null` | no | -| file\_name | Lambda function filename name | `string` | `null` | no | -| function\_name | Lambda function name | `string` | n/a | yes | -| handler | Lambda function handler | `string` | n/a | yes | -| image\_config | Container image configuration values that override the values in the container image Dockerfile. |
object({
command = list(string)
entry_point = list(string)
working_directory = string
})
| `null` | no | -| image\_uri | ECR image URI containing the function's deployment package | `string` | `null` | no | -| kinesis\_configuration | https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping |
map(object({
batch_size = number
bisect_batch_on_function_error = bool
destination_config__on_failure__destination_arn = string
event_source_arn = string
maximum_batching_window_in_seconds = number
maximum_record_age_in_seconds = number
maximum_retry_attempts = number
parallelization_factor = number
starting_position = string
starting_position_timestamp = string
tumbling_window_in_seconds = number
}))
| `{}` | no | -| layers | List of layers for this lambda function | `list(string)` | `[]` | no | -| memory\_size | Lambda function memory size | `number` | `128` | no | -| publish | Publish lambda function | `bool` | `false` | no | -| region | AWS region | `string` | n/a | yes | -| reserved\_concurrent\_executions | Reserved concurrent executions for this lambda function | `number` | `-1` | no | -| role | Lambda function role | `string` | n/a | yes | -| runtime | Lambda function runtime | `string` | `"nodejs14.x"` | no | -| sqs\_external | External SQS to consume |
object({
batch_size = number
sqs_arns = list(string)
})
| `null` | no | -| tags | Tags for this lambda function | `map(string)` | `{}` | no | -| timeout | Lambda function runtime | `number` | `300` | no | -| tracing\_config | https://www.terraform.io/docs/providers/aws/r/lambda_function.html |
object({
mode : string
})
|
{
"mode": "PassThrough"
}
| no | -| trigger | Trigger configuration for this lambda function | `any` | n/a | yes | -| vpc\_config | Lambda VPC configuration |
object({
subnet_ids : list(string)
security_group_ids : list(string)
})
|
{
"security_group_ids": [],
"subnet_ids": []
}
| no | +| [cloudwatch\_log\_retention](#input\_cloudwatch\_log\_retention) | Enable Cloudwatch logs retention | `number` | `90` | no | +| [cloudwatch\_log\_subscription](#input\_cloudwatch\_log\_subscription) | Cloudwatch log stream configuration |
object({
enable : bool
filter_pattern : string
destination_arn : string
})
|
{
"destination_arn": "",
"enable": false,
"filter_pattern": ""
}
| no | +| [description](#input\_description) | Lambda function description | `string` | `"Managed by Terraform"` | no | +| [environment](#input\_environment) | Lambda environment variables | `map(string)` | `null` | no | +| [file\_name](#input\_file\_name) | Lambda function filename name | `string` | `null` | no | +| [function\_name](#input\_function\_name) | Lambda function name | `string` | n/a | yes | +| [handler](#input\_handler) | Lambda function handler | `string` | `null` | no | +| [image\_config](#input\_image\_config) | Container image configuration values that override the values in the container image Dockerfile. |
object({
command = list(string)
entry_point = list(string)
working_directory = string
})
| `null` | no | +| [image\_uri](#input\_image\_uri) | ECR image URI containing the function's deployment package | `string` | `null` | no | +| [kinesis\_configuration](#input\_kinesis\_configuration) | https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping |
map(object({
batch_size = number
bisect_batch_on_function_error = bool
destination_config__on_failure__destination_arn = string
event_source_arn = string
maximum_batching_window_in_seconds = number
maximum_record_age_in_seconds = number
maximum_retry_attempts = number
parallelization_factor = number
starting_position = string
starting_position_timestamp = string
tumbling_window_in_seconds = number
}))
| `{}` | no | +| [layers](#input\_layers) | List of layers for this lambda function | `list(string)` | `[]` | no | +| [memory\_size](#input\_memory\_size) | Lambda function memory size | `number` | `128` | no | +| [publish](#input\_publish) | Publish lambda function | `bool` | `false` | no | +| [region](#input\_region) | AWS region | `string` | n/a | yes | +| [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | Reserved concurrent executions for this lambda function | `number` | `-1` | no | +| [role](#input\_role) | Lambda function role | `string` | n/a | yes | +| [runtime](#input\_runtime) | Lambda function runtime | `string` | `"nodejs14.x"` | no | +| [s3\_bucket](#input\_s3\_bucket) | S3 bucket name where lambda package is stored | `string` | `null` | no | +| [s3\_key](#input\_s3\_key) | S3 key where lambda package is stored | `string` | `null` | no | +| [s3\_object\_version](#input\_s3\_object\_version) | S3 object version of the lambda package | `string` | `null` | no | +| [sqs\_external](#input\_sqs\_external) | External SQS to consume |
object({
batch_size = number
sqs_arns = list(string)
})
| `null` | no | +| [tags](#input\_tags) | Tags for this lambda function | `map(string)` | `{}` | no | +| [timeout](#input\_timeout) | Lambda function runtime | `number` | `300` | no | +| [tracing\_config](#input\_tracing\_config) | https://www.terraform.io/docs/providers/aws/r/lambda_function.html |
object({
mode : string
})
|
{
"mode": "PassThrough"
}
| no | +| [trigger](#input\_trigger) | Trigger configuration for this lambda function | `any` | n/a | yes | +| [vpc\_config](#input\_vpc\_config) | Lambda VPC configuration |
object({
subnet_ids : list(string)
security_group_ids : list(string)
})
|
{
"security_group_ids": [],
"subnet_ids": []
}
| no | ## Outputs | Name | Description | |------|-------------| -| arn | AWS lambda arn | -| dlq | AWS lambda Dead Letter Queue details | -| function\_name | AWS lambda function name | -| invoke\_arn | AWS lambda invoke\_arn | -| qualified\_arn | AWS lambda qualified\_arn | -| queue | AWS lambda SQS details | -| sns\_topics | AWS lambda SNS topics if any | -| version | AWS lambda version | +| [arn](#output\_arn) | AWS lambda arn | +| [dlq](#output\_dlq) | AWS lambda Dead Letter Queue details | +| [function\_name](#output\_function\_name) | AWS lambda function name | +| [invoke\_arn](#output\_invoke\_arn) | AWS lambda invoke\_arn | +| [qualified\_arn](#output\_qualified\_arn) | AWS lambda qualified\_arn | +| [queue](#output\_queue) | AWS lambda SQS details | +| [sns\_topics](#output\_sns\_topics) | AWS lambda SNS topics if any | +| [version](#output\_version) | AWS lambda version | diff --git a/examples/s3/main.tf b/examples/s3/main.tf new file mode 100644 index 0000000..0a8e47f --- /dev/null +++ b/examples/s3/main.tf @@ -0,0 +1,103 @@ +variable "function_name" { + type = string +} + +data "aws_iam_policy_document" "assume_role" { + statement { + actions = ["sts:AssumeRole"] + + principals { + type = "Service" + identifiers = ["lambda.amazonaws.com"] + } + } +} + +# Do not use the below policy anywhere +data "aws_iam_policy_document" "policy" { + statement { + actions = ["*"] + resources = ["*"] + } +} + +resource "aws_iam_role" "lambda" { + name = var.function_name + assume_role_policy = data.aws_iam_policy_document.assume_role.json + force_detach_policies = true +} + +resource "aws_iam_role_policy" "lambda" { + name = var.function_name + role = aws_iam_role.lambda.id + + policy = data.aws_iam_policy_document.policy.json +} + +resource "random_pet" "bucket_name" { +} + +resource "aws_s3_bucket" "b" { + bucket = "ct-${random_pet.bucket_name.id}" + acl = "private" +} + +resource "aws_s3_bucket_object" "object" { + bucket = aws_s3_bucket.b.id + key = "foo/bar/baz/foo.zip" + source = "${path.module}/../../test/fixtures/foo.zip" + etag = filemd5("${path.module}/../../test/fixtures/foo.zip") +} + + +module "s3" { + + source = "../../" + + s3_bucket = aws_s3_bucket.b.id + s3_key = aws_s3_bucket_object.object.key + function_name = var.function_name + handler = "index.handler" + role = aws_iam_role.lambda.arn + trigger = { + type = "api-gateway" + } + environment = { + "LOREM" = "IPSUM" + } + region = "us-east-1" + tags = { + "Foo" : var.function_name + } +} + +output "arn" { + description = "AWS lambda arn" + value = module.s3.arn +} + +output "qualified_arn" { + description = "AWS lambda qualified_arn" + value = module.s3.qualified_arn +} + +output "invoke_arn" { + description = "AWS lambda invoke_arn" + value = module.s3.invoke_arn +} + +output "version" { + description = "AWS lambda version" + value = module.s3.version +} + +output "dlq" { + description = "AWS lambda Dead Letter Queue details" + value = module.s3.dlq +} + +output "queue" { + description = "AWS lambda SQS details" + value = module.s3.queue +} + diff --git a/examples/s3_versioning/main.tf b/examples/s3_versioning/main.tf new file mode 100644 index 0000000..57bfea1 --- /dev/null +++ b/examples/s3_versioning/main.tf @@ -0,0 +1,107 @@ +variable "function_name" { + type = string +} + +data "aws_iam_policy_document" "assume_role" { + statement { + actions = ["sts:AssumeRole"] + + principals { + type = "Service" + identifiers = ["lambda.amazonaws.com"] + } + } +} + +# Do not use the below policy anywhere +data "aws_iam_policy_document" "policy" { + statement { + actions = ["*"] + resources = ["*"] + } +} + +resource "aws_iam_role" "lambda" { + name = var.function_name + assume_role_policy = data.aws_iam_policy_document.assume_role.json + force_detach_policies = true +} + +resource "aws_iam_role_policy" "lambda" { + name = var.function_name + role = aws_iam_role.lambda.id + + policy = data.aws_iam_policy_document.policy.json +} + +resource "random_pet" "bucket_name" { +} + +resource "aws_s3_bucket" "b" { + bucket = "ct-${random_pet.bucket_name.id}" + acl = "private" + versioning { + enabled = true + } +} + +resource "aws_s3_bucket_object" "object" { + bucket = aws_s3_bucket.b.id + key = "foo/bar/baz/foo.zip" + source = "${path.module}/../../test/fixtures/foo.zip" + etag = filemd5("${path.module}/../../test/fixtures/foo.zip") +} + + +module "s3" { + + source = "../../" + + s3_bucket = aws_s3_bucket.b.id + s3_key = aws_s3_bucket_object.object.key + s3_object_version = aws_s3_bucket_object.object.version_id + function_name = var.function_name + handler = "index.handler" + role = aws_iam_role.lambda.arn + trigger = { + type = "api-gateway" + } + environment = { + "LOREM" = "IPSUM" + } + region = "us-east-1" + tags = { + "Foo" : var.function_name + } +} + +output "arn" { + description = "AWS lambda arn" + value = module.s3.arn +} + +output "qualified_arn" { + description = "AWS lambda qualified_arn" + value = module.s3.qualified_arn +} + +output "invoke_arn" { + description = "AWS lambda invoke_arn" + value = module.s3.invoke_arn +} + +output "version" { + description = "AWS lambda version" + value = module.s3.version +} + +output "dlq" { + description = "AWS lambda Dead Letter Queue details" + value = module.s3.dlq +} + +output "queue" { + description = "AWS lambda SQS details" + value = module.s3.queue +} + diff --git a/main.tf b/main.tf index c6170a2..518fe38 100644 --- a/main.tf +++ b/main.tf @@ -20,6 +20,9 @@ resource "aws_lambda_function" "lambda" { filename = var.file_name function_name = var.function_name + s3_bucket = var.s3_bucket + s3_key = var.s3_key + s3_object_version = var.s3_object_version layers = var.layers handler = var.handler role = var.role @@ -31,7 +34,7 @@ resource "aws_lambda_function" "lambda" { publish = var.publish source_code_hash = local.source_code_hash image_uri = var.image_uri - package_type = var.file_name != null ? "Zip" : "Image" + package_type = var.image_uri != null ? "Image" : "Zip" dynamic "image_config" { for_each = var.image_config == null ? [] : [var.image_config] diff --git a/test/lambda_aws_test.go b/test/lambda_aws_test.go index 84fcd68..1f9eff3 100644 --- a/test/lambda_aws_test.go +++ b/test/lambda_aws_test.go @@ -28,6 +28,32 @@ func TestLambda_apiGatewayTriggerExample(t *testing.T) { require.Regexp(t, regexp.MustCompile("arn:aws:apigateway:us-east-1:lambda:path/*"), terraform.Output(t, terraformOptions, "invoke_arn")) } +func TestLambda_s3Example(t *testing.T) { + t.Parallel() + + functionName := fmt.Sprintf("lambda-%s", random.UniqueId()) + exampleDir := "../examples/s3/" + + terraformOptions := SetupExample(t, functionName, exampleDir, nil) + t.Logf("Terraform module inputs: %+v", *terraformOptions) + defer terraform.Destroy(t, terraformOptions) + + TerraformApplyAndValidateOutputs(t, terraformOptions) +} + +func TestLambda_s3VersioningExample(t *testing.T) { + t.Parallel() + + functionName := fmt.Sprintf("lambda-%s", random.UniqueId()) + exampleDir := "../examples/s3_versioning/" + + terraformOptions := SetupExample(t, functionName, exampleDir, nil) + t.Logf("Terraform module inputs: %+v", *terraformOptions) + defer terraform.Destroy(t, terraformOptions) + + TerraformApplyAndValidateOutputs(t, terraformOptions) +} + func TestLambda_kinesisTriggerBasicExample(t *testing.T) { t.Parallel() diff --git a/triggers/api_gateway/README.md b/triggers/api_gateway/README.md index cfefc1b..8aa0519 100644 --- a/triggers/api_gateway/README.md +++ b/triggers/api_gateway/README.md @@ -1,28 +1,38 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by API Gateways ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_permission.allow_apigateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable API Gateway trigger | `bool` | `false` | no | -| lambda\_function\_arn | Lambda arn | `string` | n/a | yes | +| [enable](#input\_enable) | Enable API Gateway trigger | `bool` | `false` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda arn | `string` | n/a | yes | ## Outputs -No output. +No outputs. diff --git a/triggers/cloudwatch_event_schedule/README.md b/triggers/cloudwatch_event_schedule/README.md index c25f8dd..573b7a8 100644 --- a/triggers/cloudwatch_event_schedule/README.md +++ b/triggers/cloudwatch_event_schedule/README.md @@ -1,29 +1,41 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by Cloudwatch Event Schedule ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_cloudwatch_event_rule.rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource | +| [aws_cloudwatch_event_target.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource | +| [aws_lambda_permission.allow_cloudwatch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable module | `bool` | `false` | no | -| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | -| schedule\_config | CloudWatch event schedule configuration |
object({
name : string
description : string
schedule_expression : string
})
| n/a | yes | +| [enable](#input\_enable) | Enable module | `bool` | `false` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda function arn | `string` | n/a | yes | +| [schedule\_config](#input\_schedule\_config) | CloudWatch event schedule configuration |
object({
name : string
description : string
schedule_expression : string
})
| n/a | yes | ## Outputs -No output. +No outputs. diff --git a/triggers/cloudwatch_event_trigger/README.md b/triggers/cloudwatch_event_trigger/README.md index 3ae57f2..fbe4ec8 100644 --- a/triggers/cloudwatch_event_trigger/README.md +++ b/triggers/cloudwatch_event_trigger/README.md @@ -1,29 +1,41 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by Cloudwatch Event Trigger ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_cloudwatch_event_rule.event_rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource | +| [aws_cloudwatch_event_target.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource | +| [aws_lambda_permission.invoke-from-events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable module | `bool` | `false` | no | -| event\_config | Cloudwatch event configuration |
object({
name : string
description : string
event_pattern : string
})
| n/a | yes | -| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | +| [enable](#input\_enable) | Enable module | `bool` | `false` | no | +| [event\_config](#input\_event\_config) | Cloudwatch event configuration |
object({
name : string
description : string
event_pattern : string
})
| n/a | yes | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda function arn | `string` | n/a | yes | ## Outputs -No output. +No outputs. diff --git a/triggers/cloudwatch_logs/README.md b/triggers/cloudwatch_logs/README.md index 9114f81..b05ca6c 100644 --- a/triggers/cloudwatch_logs/README.md +++ b/triggers/cloudwatch_logs/README.md @@ -1,29 +1,39 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by Cloudwatch logs ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_permission.allow_cloudwatch_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable module | `bool` | `false` | no | -| lambda\_function\_arn | Lambda arn | `string` | n/a | yes | -| region | AWS region | `string` | n/a | yes | +| [enable](#input\_enable) | Enable module | `bool` | `false` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda arn | `string` | n/a | yes | +| [region](#input\_region) | AWS region | `string` | n/a | yes | ## Outputs -No output. +No outputs. diff --git a/triggers/cognito_idp/README.md b/triggers/cognito_idp/README.md index a3e35d6..d4edc57 100644 --- a/triggers/cognito_idp/README.md +++ b/triggers/cognito_idp/README.md @@ -1,28 +1,38 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by Cognito IDP ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_permission.allow_invocation_from_cognito_idp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable module | `bool` | `false` | no | -| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | +| [enable](#input\_enable) | Enable module | `bool` | `false` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda function arn | `string` | n/a | yes | ## Outputs -No output. +No outputs. diff --git a/triggers/kinesis/README.md b/triggers/kinesis/README.md index d5d132e..7398417 100644 --- a/triggers/kinesis/README.md +++ b/triggers/kinesis/README.md @@ -6,15 +6,25 @@ No requirements. | Name | Version | |------|---------| -| aws | n/a | +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_event_source_mapping.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| kinesis\_configuration | https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping |
map(object({
batch_size = number
bisect_batch_on_function_error = bool
destination_config__on_failure__destination_arn = string
event_source_arn = string
maximum_batching_window_in_seconds = number
maximum_record_age_in_seconds = number
maximum_retry_attempts = number
parallelization_factor = number
starting_position = string
starting_position_timestamp = string
tumbling_window_in_seconds = number
}))
| `{}` | no | -| lambda\_function\_arn | Lambda arn | `string` | n/a | yes | +| [kinesis\_configuration](#input\_kinesis\_configuration) | https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping |
map(object({
batch_size = number
bisect_batch_on_function_error = bool
destination_config__on_failure__destination_arn = string
event_source_arn = string
maximum_batching_window_in_seconds = number
maximum_record_age_in_seconds = number
maximum_retry_attempts = number
parallelization_factor = number
starting_position = string
starting_position_timestamp = string
tumbling_window_in_seconds = number
}))
| `{}` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda arn | `string` | n/a | yes | ## Outputs -No output. +No outputs. diff --git a/triggers/sqs/README.md b/triggers/sqs/README.md index ff205ff..e169833 100644 --- a/triggers/sqs/README.md +++ b/triggers/sqs/README.md @@ -1,35 +1,50 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by SQS and optionally subscribe to SNS topics ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_event_source_mapping.event_source_mapping](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource | +| [aws_sns_topic_subscription.to-sqs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription) | resource | +| [aws_sqs_queue.sqs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource | +| [aws_sqs_queue.sqs-deadletter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource | +| [aws_sqs_queue_policy.SendMessage](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource | +| [aws_iam_policy_document.SendMessage](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable module | `bool` | `false` | no | -| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | -| sqs\_config | SQS config |
object({
sns_topics : list(string)
fifo : bool
sqs_name : string
visibility_timeout_seconds : number
batch_size : number
})
| n/a | yes | -| tags | Tags | `map(string)` | n/a | yes | +| [enable](#input\_enable) | Enable module | `bool` | `false` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda function arn | `string` | n/a | yes | +| [sqs\_config](#input\_sqs\_config) | SQS config |
object({
sns_topics : list(string)
fifo : bool
sqs_name : string
visibility_timeout_seconds : number
batch_size : number
})
| n/a | yes | +| [tags](#input\_tags) | Tags | `map(string)` | n/a | yes | ## Outputs | Name | Description | |------|-------------| -| dlq | Dead letter queue details | -| queue | SQS queue details | -| queue\_arn | SQS ARN | -| queue\_id | SQS endpoint | +| [dlq](#output\_dlq) | Dead letter queue details | +| [queue](#output\_queue) | SQS queue details | +| [queue\_arn](#output\_queue\_arn) | SQS ARN | +| [queue\_id](#output\_queue\_id) | SQS endpoint | diff --git a/triggers/sqs_external/README.md b/triggers/sqs_external/README.md index 7bce7a8..6a648d6 100644 --- a/triggers/sqs_external/README.md +++ b/triggers/sqs_external/README.md @@ -6,15 +6,25 @@ No requirements. | Name | Version | |------|---------| -| aws | n/a | +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_event_source_mapping.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| lambda\_function\_arn | Lambda arn | `string` | n/a | yes | -| sqs\_external | External SQS to consume |
object({
batch_size = number
sqs_arns = list(string)
})
| `null` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda arn | `string` | n/a | yes | +| [sqs\_external](#input\_sqs\_external) | External SQS to consume |
object({
batch_size = number
sqs_arns = list(string)
})
| `null` | no | ## Outputs -No output. +No outputs. diff --git a/triggers/step_function/README.md b/triggers/step_function/README.md index fbd59ac..796b8e7 100644 --- a/triggers/step_function/README.md +++ b/triggers/step_function/README.md @@ -1,29 +1,39 @@ # Trigger plugin for the AWS Lambda module -## Introduction +## Introduction Allow this lambda to be triggered by Step functions ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.13 | -| aws | ~> 3.0 | +| [terraform](#requirement\_terraform) | >= 0.13 | +| [aws](#requirement\_aws) | ~> 3.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 3.0 | +| [aws](#provider\_aws) | ~> 3.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_lambda_permission.allow_invocation_from_sfn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| enable | Enable module | `bool` | `false` | no | -| lambda\_function\_arn | Lambda function arn | `string` | n/a | yes | -| region | AWS region | `string` | n/a | yes | +| [enable](#input\_enable) | Enable module | `bool` | `false` | no | +| [lambda\_function\_arn](#input\_lambda\_function\_arn) | Lambda function arn | `string` | n/a | yes | +| [region](#input\_region) | AWS region | `string` | n/a | yes | ## Outputs -No output. +No outputs. diff --git a/variables.tf b/variables.tf index 9295e41..054b42a 100644 --- a/variables.tf +++ b/variables.tf @@ -20,6 +20,24 @@ variable "image_config" { default = null } +variable "s3_bucket" { + description = "S3 bucket name where lambda package is stored" + default = null + type = string +} + +variable "s3_key" { + description = "S3 key where lambda package is stored" + default = null + type = string +} + +variable "s3_object_version" { + description = "S3 object version of the lambda package" + default = null + type = string +} + variable "layers" { description = "List of layers for this lambda function" type = list(string) @@ -60,6 +78,8 @@ variable "runtime" { type = string } + + variable "timeout" { description = "Lambda function runtime" default = 300