Code Monkey home page Code Monkey logo

terraform-aws-email-files-dropped-in-s3's Introduction

Terraform Module: email-files-dropped-in-s3

This Terraform module sets up an AWS Lambda function that sends an email via Amazon SES whenever a new object is created in a specified S3 bucket.

The story behind this module

I saw this conversation on the AWS Reddit about this topic and realized I'd also benefit greatly from such a tool.

My use case is to save time reading the CSV daily business report files "conveniently" dropped into an S3 bucket by the AWS Marketplace, where I'm selling some AWS cost optimization tools.

Previously I had to log in using MFA, go to S3, find the bucket, browse to the file, etc, which took a loooong time.

I spent a few hours building this (with plenty of help from ChatGPT), but now that I have this, the file I'm interested in is delivered by email immediately and I just need to open it in a few seconds.

The email looks like this:

Screenshot 2023-03-08 at 22 21 46

Usage

module "email_sender" {
  source  = "LeanerCloud/email-files-dropped-in-s3/aws"
  version = "0.0.3"

  bucket_name = "my-s3-bucket"
  email_from  = "[email protected]"
  email_to    = "[email protected]"
  kms_key_arn = "arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/yyyyyyyyyyyyyyyyy"
  }

Variables

Name Description Type Default Required
bucket_name The name of the S3 bucket that will trigger the Lambda function string n/a yes
email_from The email address of the sender string n/a yes
email_to The email address of the recipient string n/a yes
kms_key_arn The ARN of the KMS key used to encrypt and decrypt sensitive data string "" no
filter_paths A set of S3 object key prefixes to filter on. Only objects with keys that match at least one of these prefixes will trigger the Lambda function. string [""] no

Outputs

Name Description
lambda_function_arn ARN of the Lambda function
s3_bucket_name Name of the S3 bucket
email_sender_role_arn ARN of the IAM role for the Lambda function
email_sender_role_name Name of the IAM role for the Lambda function

Contributing

If you find this useful you can always buy me a coffee.

You may also want to try my LeanerCloud.com AWS cost optimization tools, chances are they can save you some money.

License

This module is distributed under the MIT License, see the LICENSE file for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.