Coder Social home page Coder Social logo

sethdford / aws-lambda-copy-s3-objects Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eleven41/aws-lambda-copy-s3-objects

0.0 2.0 0.0 10 KB

An AWS Lambda function to copy objects from a source S3 bucket to a target S3 bucket as they are added to the source bucket.

License: MIT License

JavaScript 100.00%

aws-lambda-copy-s3-objects's Introduction

An AWS Lambda Based Function to Copy S3 Objects

With this AWS Lambda function, you can copy objects from a source S3 bucket to one or more target S3 buckets as they are added to the source bucket.

Configuration

IAM Role

Create an IAM role with the following policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1430872797000",
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketTagging",
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "*"
            ]
        },
        {
            "Sid": "Stmt1430872844000",
            "Effect": "Allow",
            "Action": [
                "cloudwatch:*"
            ],
            "Resource": [
                "*"
            ]
        },
        {
            "Sid": "Stmt1430872852000",
            "Effect": "Allow",
            "Action": [
                "logs:*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

S3 Buckets

  1. Ensure you have a source and target bucket. They do not need to reside in the same region.
  2. Configure your S3 buckets (see below)

Building the Lambda Package

  1. Clone this repo
git clone [email protected]:eleven41/aws-lambda-copy-s3-objects.git
cd aws-copy-encrypt-s3-objects
  1. Install requirements
npm install async
npm install aws-sdk
  1. Zip up the folder using your favourite zipping utility

Lambda Function

  1. Create a new Lambda function.
  2. Upload the ZIP package to your lambda function.
  3. Add an event source to your Lambda function:
  • Event Source Type: S3
  • Bucket: your source bucket
  • Event Type: Object Created
  1. Set your Lambda function to execute using the IAM role you created above.

Configuration

Configuration is performed by setting tags on the source bucket.

Tag Name Required
TargetBucket Yes

TargetBucket - A space-separated list of buckets to which the objects will be copied. Optionally, the bucket names can contain a @ character followed by a region to indicate that the bucket resides in a different region.

For example: my-target-bucket1 my-target-bucket1@us-west-2 my-target-bucket3@us-east-1

At this point, if you upload a file to your source bucket, the file should be copied to the target bucket(s).

aws-lambda-copy-s3-objects's People

Contributors

mwhouser avatar

Watchers

 avatar  avatar

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.