drone-lambda

Deploying Lambda code with drone CI to an existing function
Build or Download a binary
The pre-compiled binaries can be downloaded from release page. Support the following OS type.
- Windows amd64/386
- Linux amd64/386
- Darwin amd64/386
With Go
installed
$ go get -u -v github.com/appleboy/drone-lambda
or build the binary with the following command:
$ make build
Docker
Build the docker image with the following commands:
$ make docker
Please note incorrectly building the image for the correct x64 linux and with
CGO disabled will result in an error when running the Docker image:
docker: Error response from daemon: Container command
'/bin/drone-lambda' not found or does not exist..
Usage
There are three ways to send notification.
Usage from binary
Update lambda function from zip file.
$ drone-lambda --region ap-southeast-1 \
--access-key xxxx \
--secret-key xxxx \
--function-name upload-s3 \
--zip-file deployment.zip
Update lambda function from s3 object.
$ drone-lambda --region ap-southeast-1 \
--access-key xxxx \
--secret-key xxxx \
--function-name upload-s3 \
--s3-bucket some-bucket \
--s3-key lambda-dir/lambda-project-${DRONE_BUILD_NUMBER}.zip
Usage from docker
Update lambda function from zip file.
docker run --rm \
-e AWS_ACCESS_KEY_ID=xxxxxxx \
-e AWS_SECRET_ACCESS_KEY=xxxxxxx \
-e FUNCTION_NAME=upload-s3 \
-e ZIP_FILE=deployment.zip \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-lambda
Update lambda function from s3 object.
docker run --rm \
-e AWS_ACCESS_KEY_ID=xxxxxxx \
-e AWS_SECRET_ACCESS_KEY=xxxxxxx \
-e FUNCTION_NAME=upload-s3 \
-e S3_BUCKET=some-bucket \
-e S3_KEY=lambda-project.zip \
appleboy/drone-lambda
Usage from drone ci
Update lambda function, execute from the working directory:
docker run --rm \
-e AWS_ACCESS_KEY_ID=xxxxxxx \
-e AWS_SECRET_ACCESS_KEY=xxxxxxx \
-e FUNCTION_NAME=upload-s3 \
-e ZIP_FILE=deployment.zip \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-lambda
AWS Policy
Add the following AWS policy if you want to integrate with CI/CD tools like Jenkins, GitLab Ci or Drone.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"iam:ListRoles",
"lambda:UpdateFunctionCode",
"lambda:CreateFunction"
],
"Resource": "arn:aws:logs:*:*:*"
}
]
}