/terraform-aws-benthos-serverless

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

Primary LanguageHCLMIT LicenseMIT

terraform-aws-benthos-serverless

a Terraform module for deploying Benthos as an AWS Lambda Function with support for Gomplate templated config

Getting Started

# 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 >= 1.0.0
archive 2.2.0
aws >= 3.0.0
get 0.1.1

Providers

Name Version
archive 2.2.0
aws >= 3.0.0
get 0.1.1

Modules

No modules.

Resources

Name Type
aws_cloudwatch_log_group.this resource
aws_iam_role.this resource
aws_lambda_function.this resource
aws_lambda_layer_version.config resource
aws_lambda_layer_version.gomplate resource
get_artifact.benthos resource
get_artifact.gomplate resource
archive_file.config data source
aws_iam_policy_document.this data source
aws_iam_policy_document.trust data source

Inputs

Name Description Type Default Required
benthos_version benthos artifact version string "3.62.0" no
config gomplate templated benthos config (YAML format) string n/a yes
config_datasources map of gomplate datasources referenced by config map(string) {} no
description lambda function description string "benthos-lambda" no
environment map of additional environment variables map(string) {} no
gomplate_version gomplate-lambda-extension artifact version string "0.2.0" no
memory_size amount of memory in MB your Lambda Function can use at runtime number 128 no
name function name string n/a yes
reserved_concurrent_executions amount of reserved concurrent executions for this lambda function number -1 no
retention_in_days function log retention in days number 7 no
role_arn execution role arn string null no
role_name override default execution role name string null no
security_group_ids list of vpc security group ids list(string) [] no
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 list of vpc subnet ids list(string) [] no
timeout function timeout in seconds number 3 no

Outputs

Name Description
arn function arn
id function name
role_arn function role arn
role_id function role name

License

Licensed under the MIT License
Copyright (c) 2022 Chris Ludden