Skip to content

saka2jp/s3-unzipper-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s3-unzipper-go

Description

unzip uploaded zip file to another S3 bucket via AWS Lambda in Go

sequence

Production

prerequisites

You have to prepare credentials with proper policies.

And,

  • install aws-cli
  • install aws-sam-cli. Docker is also required. Follow the instruction here.
  • install direnv
  • install saw
    • you can watch CloudWatch logs on your terminal
  • set environment variables to .envrc.sample and remove .sample.
    • ZIPPED_ARTIFACT_BUCKET is S3 bucket name. It's S3① in the sequence and should be unique globally.
    • UNZIPPED_ARTIFACT_BUCKET is S3 bucket name. It's S3② in the sequence and should be unique globally.
    • STACK_BUCKET is S3 bucket name for artifacts of SAM and should be unique globally.

deploy

$ dep ensure                       # to resolve dependency
$ aws s3 mb "s3://${STACK_BUCKET}" # for artifacts of SAM
$ make deploy

behavior

Deploy is required before checking behavior.

$ saw groups
/aws/lambda/stack-unzipper-lambda-Unzipper-XXXXXXXXXXXX

$ saw watch /aws/lambda/stack-unzipper-lambda-Unzipper-XXXXXXXXXXXX

# open another window
$ aws s3 cp testdata/sample.zip "s3://${ZIPPED_ARTIFACT_BUCKET}"

Local

You can test a behavior on test (main_test.go).

In the test, setup prepares 2 real S3 buckets because SAM local doesn't support local emulation of an S3.

One is for an even source that triggers an AWS Lambda and another is for a destination of unzipped artifacts.

Because S3 buckets created at the test are deleted on every test execution, idempotency is guaranteed.

Articles (Japanese)

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks