Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Greyeye committed Jun 10, 2021
0 parents commit 08e29ba
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# S3 Event Trigger Lambda Code Sample

This project is a code sample to handle S3 Event to Copy to other bucket.
Uses io.pipe to copy dynamically from the event source bucket to specified destination.


Tested with a large file (upto 2GigByte) with 256MByte Memory Lambda.



## Building and testing the code
### Build
```bash
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main ./... &&zip -r main.zip main
```
### Test
```bash
go test -coverprofile=coverage.out |go tool cover -html=coverage.out
```

## Required Lambda Configuration
Environment Variable **"destinationBucket"** is a mandatory requirement. Please add it on your lambda configuration.


## How to setup a S3 Bucket Trigger Configurations
1. Create Lambda, upload the zipped code, setup environment variable "destinationBucket"
2. Make sure Lambda has assigned with the IAM Role with GetObject to the source bucket, and PutItem to destination bucket.
3. Goto Source Bucket, and configure [Event notifications](https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html)
and add Put event, point to ARN or the name of the lambda you saved in the step 1.
4. Upload a test file to the source bucket and see it gets copied to the destination bucket.

0 comments on commit 08e29ba

Please sign in to comment.