Giter Club home page Giter Club logo

s3copy's Introduction

s3copy

A lambda function to copy objects from n to m S3 Buckets where n, m >= 1

Deployment

or

  • Checkout the latest release code go get github.com/maknahar/copys3
  • Build and generate the deployment file GOOS=linux go build -o main main.go && zip deployment.zip main
  • Upload the deployment file to lambda
  • Set the configuration

Handler function name: main

Config

This Lambda Function expect the list of source and destination buckets in a JSON file.

Config File Format

Config File is a map of input s3 bucket and detail to copy changes to destination.

The function can take events from an SQS as well if source bucket put all event to an SQS.

The function can take events from an SQS where SQS is subscribed to an SNS and source bucket publish a message to an SNS on every change.

To Support SQS processing add SQS URL sqs and SQS region sqsRegion in the config file. Otherwise, Leave them empty "" or remove the keys.

{
  "source-bucket": {
    "region": "us-east-1",
    "sqs": "URL of SQS where all S3 change events are stored",
    "sqsRegion": "us-east-1",
    "destinations": [
      "destination-bucket-1",
      "destination-bucket-2"
    ]
  },
  "another-source-bucket": {
    "region": "us-east-1",
    "sqs": "SQS URL",
    "sqsRegion": "us-east-1",
    "destinations": [
      "destination-bucket-1",
      "destination-bucket-3"
    ]
  }
}

With above configuration, any object put in source-bucket will be copied to destination-bucket-1 & destination-bucket-2 and any object put in another-source-bucket will be copied to destination-bucket-1 & destination-bucket-3.

Env Var

This Lambda function can be configured in two ways.

  • Either give a public url of config file via CONFIG_FILE
  • or provide base64 encoded value of configuration via CONFIG. You can online tools like www.base64encode.org to encode config content.

If both are provided CONFIG_FILE value will take precedence.

  • CONFIG_FILE : URL of configuration file

  • CONFIG : Base64 Encoded string of content of CONFIG_FILE

NOTE:

Make sure Lambda function have required access to source and destination bucket.

Contribution

All contributions are welcome. Either via PR or Issue.

s3copy's People

Contributors

maknahar avatar

Stargazers

 avatar

Watchers

 avatar

s3copy's Issues

Detect the copy cycle in configuration

Detect if there is any cycle that is configured in the configuration. For example, A->B->C->A where A, B, and C are S3 bucket name.

This type of configuration can result in infinite copy loop that will lead to a very high bill.

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.