An open API service indexing awesome lists of open source software.

https://github.com/cludden/terraform-aws-benthos-serverless

a Terraform module for deploying Benthos as an AWS Lambda function with dynamic configuration via Gomplate
https://github.com/cludden/terraform-aws-benthos-serverless

Last synced: 4 months ago
JSON representation

a Terraform module for deploying Benthos as an AWS Lambda function with dynamic configuration via Gomplate

Awesome Lists containing this project

README

          

# terraform-aws-benthos-serverless
a Terraform module for deploying [Benthos](https://www.benthos.dev/) as an AWS Lambda Function with support for [Gomplate](https://docs.gomplate.ca/) templated config

## Getting Started
```terraform
# store sensitive configuration in ssm parameter store
resource "aws_ssm_parameter" "key" {
name = "/benthos-lambda-example/key"
type = "SecureString"
value = var.key
}

# deploy benthos lambda function using ssm as config datasource
module "benthos_lambda" {
source = "cludden/aws/benthos-serverless"

name = "benthos-lambda-example"

config_datasources = {
ssm = "aws+smp:///benthos-lambda-example"
}

config = <<-YAML
pipeline:
processors:
# format slack chat.postMessage payload
- bloblang: |
root = this
sha256 = content().hash("hmac_sha256", "{{ (ds "ssm" "key").Value }}").encode("hex")

# log response
- log:
message: "$${!content().string()}"

output:
switch:
retry_until_success: false
cases:
- check: errored()
output:
reject: "$${!error()}"
- output:
sync_response: {}
YAML
}
```

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.0.0 |
| [archive](#requirement\_archive) | 2.2.0 |
| [aws](#requirement\_aws) | >= 3.0.0 |
| [get](#requirement\_get) | 0.1.1 |

## Providers

| Name | Version |
|------|---------|
| [archive](#provider\_archive) | 2.2.0 |
| [aws](#provider\_aws) | >= 3.0.0 |
| [get](#provider\_get) | 0.1.1 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_cloudwatch_log_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_lambda_function.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_layer_version.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_layer_version) | resource |
| [aws_lambda_layer_version.gomplate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_layer_version) | resource |
| [get_artifact.benthos](https://registry.terraform.io/providers/cludden/get/0.1.1/docs/resources/artifact) | resource |
| [get_artifact.gomplate](https://registry.terraform.io/providers/cludden/get/0.1.1/docs/resources/artifact) | resource |
| [archive_file.config](https://registry.terraform.io/providers/hashicorp/archive/2.2.0/docs/data-sources/file) | data source |
| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.trust](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [benthos\_version](#input\_benthos\_version) | benthos artifact version | `string` | `"3.62.0"` | no |
| [config](#input\_config) | gomplate templated benthos config (YAML format) | `string` | n/a | yes |
| [config\_datasources](#input\_config\_datasources) | map of gomplate datasources referenced by config | `map(string)` | `{}` | no |
| [description](#input\_description) | lambda function description | `string` | `"benthos-lambda"` | no |
| [environment](#input\_environment) | map of additional environment variables | `map(string)` | `{}` | no |
| [gomplate\_version](#input\_gomplate\_version) | gomplate-lambda-extension artifact version | `string` | `"0.2.0"` | no |
| [memory\_size](#input\_memory\_size) | amount of memory in MB your Lambda Function can use at runtime | `number` | `128` | no |
| [name](#input\_name) | function name | `string` | n/a | yes |
| [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | amount of reserved concurrent executions for this lambda function | `number` | `-1` | no |
| [retention\_in\_days](#input\_retention\_in\_days) | function log retention in days | `number` | `7` | no |
| [role\_arn](#input\_role\_arn) | execution role arn | `string` | `null` | no |
| [role\_name](#input\_role\_name) | override default execution role name | `string` | `null` | no |
| [security\_group\_ids](#input\_security\_group\_ids) | list of vpc security group ids | `list(string)` | `[]` | no |
| [statements](#input\_statements) | customize role policy statements |

list(object({
actions = list(string)
conditions = optional(list(object({
test = string
variable = string
values = list(string)
})))
effect = optional(string)
resources = list(string)
}))
| `[]` | no |
| [subnet\_ids](#input\_subnet\_ids) | list of vpc subnet ids | `list(string)` | `[]` | no |
| [timeout](#input\_timeout) | function timeout in seconds | `number` | `3` | no |

## Outputs

| Name | Description |
|------|-------------|
| [arn](#output\_arn) | function arn |
| [id](#output\_id) | function name |
| [role\_arn](#output\_role\_arn) | function role arn |
| [role\_id](#output\_role\_id) | function role name |

## License
Licensed under the [MIT License](LICENSE.md)
Copyright (c) 2022 Chris Ludden