unzip uploaded zip file to another S3 bucket via AWS Lambda in Go
unzip uploaded zip file to another S3 bucket via AWS Lambda in Go
You have to prepare credentials with proper policies.
And,
$ dep ensure # to resolve dependency
$ aws s3 mb "s3://${STACK_BUCKET}" # for artifacts of SAM
$ make deploy
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}"
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.