Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/miquido/terraform-ses-email-forwarder-lambda


https://github.com/miquido/terraform-ses-email-forwarder-lambda

Last synced: 5 days ago
JSON representation

Awesome Lists containing this project

README

        

[![Miquido][logo]](https://www.miquido.com/)

# terraform-ses-email-forwarder-lambda

Lambda used to forward messages received by SES and S3 to an external mailbox
---
**Terraform Module**

GitLab Repository: https://gitlab.com/miquido/terraform/terraform-ses-email-forwarder-lambda

## Usage

Terraform:

```hcl
module "ses-email-forwarder-lambda" {
source = "git::ssh://[email protected]:miquido/terraform/terraform-ses-email-forwarder-lambda.git?ref=master"

name = "main"
namespace = "project"
stage = "example"
ses_region = "eu-west-1"
mail_sender = "[email protected]"
mail_recipient = "[email protected]"
mail_s3_bucket = aws_s3_bucket.example.id
mail_s3_bucket_prefix = "emails/example.com/"
reserved_concurrent_executions = -1
}
```

### Developer notes

* It is recommended to set `MailSender` environment variable carefully to not create email loop in case of receving bounce message (which will be forwarded again, and again..)
* Highly based on: https://aws.amazon.com/blogs/messaging-and-targeting/forward-incoming-email-to-an-external-destination/

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13 |
| [archive](#requirement\_archive) | >= 1.2 |
| [aws](#requirement\_aws) | ~> 4.7 |

## Providers

| Name | Version |
|------|---------|
| [archive](#provider\_archive) | >= 1.2 |
| [aws](#provider\_aws) | ~> 4.7 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| [label](#module\_label) | git::https://github.com/cloudposse/terraform-terraform-label.git | 0.8.0 |

## Resources

| Name | Type |
|------|------|
| [aws_cloudwatch_log_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_iam_role.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
| [aws_lambda_alias.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_alias) | resource |
| [aws_lambda_function.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_permission.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
| [archive_file.lambda](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [attributes](#input\_attributes) | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
| [delimiter](#input\_delimiter) | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
| [log\_retention](#input\_log\_retention) | Specifies the number of days you want to retain log events in the specified log group | `number` | `7` | no |
| [mail\_recipient](#input\_mail\_recipient) | Email address used as "To" value to send an email | `string` | n/a | yes |
| [mail\_s3\_bucket](#input\_mail\_s3\_bucket) | The ID of the bucket where SES saves raw received email messages | `string` | n/a | yes |
| [mail\_s3\_bucket\_prefix](#input\_mail\_s3\_bucket\_prefix) | Key prefix of the email objects used to store emails by SES (should NOT end with a trailing slash `/`) | `string` | n/a | yes |
| [mail\_sender](#input\_mail\_sender) | Email address used as "From" value to send an email | `string` | n/a | yes |
| [name](#input\_name) | Solution name, e.g. 'app' or 'cluster' | `string` | `"app"` | no |
| [namespace](#input\_namespace) | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | `string` | n/a | yes |
| [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. See: https://docs.aws.amazon.com/lambda/latest/dg/scaling.html | `number` | `-1` | no |
| [ses\_region](#input\_ses\_region) | Specifies the AWS region of SES to be used for sending emails. When not specified default aws provider region is used. | `string` | `""` | no |
| [stage](#input\_stage) | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | `string` | n/a | yes |
| [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| [lambda\_arn](#output\_lambda\_arn) | The ARN of created AWS Lambda function |

## Makefile Targets
```text
Available targets:

help Help screen
help/all Display help for all targets
help/short This help short screen
lint Lint Terraform code

```

## Developing

1. Make changes in terraform files

2. Regenerate documentation

```bash
bash <(git archive [email protected]:miquido/terraform/terraform-readme-update.git master update.sh | tar -xO)
```

3. Run lint

```
make lint
```

## Copyright

Copyright © 2017-2022 [Miquido](https://miquido.com)

### Contributors

| [![Konrad Obal][k911_avatar]][k911_homepage]
[Konrad Obal][k911_homepage] |
|---|

[k911_homepage]: https://github.com/k911
[k911_avatar]: https://github.com/k911.png?size=150

[logo]: https://www.miquido.com/img/logos/logo__miquido.svg
[website]: https://www.miquido.com/
[gitlab]: https://gitlab.com/miquido
[github]: https://github.com/miquido
[bitbucket]: https://bitbucket.org/miquido