-
Notifications
You must be signed in to change notification settings - Fork 10
Deployment
assafkamil edited this page Jan 27, 2021
·
2 revisions
Flyway lambda can either be built from source or deployed from the project's releases.
Each release includes the code, a compiled jar, and a fat jar (flyway-all.jar) ready to be deployed as a lambda. Download the latest fat jar
wget https://github.com/Geekoosh/flyway-lambda/releases/latest/download/flyway-all.jar
Create lambda execution role and attach the basic execution policy for CloudWatch logs support
aws iam create-role --role-name flyway-lambda-role --assume-role-policy-document \
'{"Version": "2012-10-17","Statement": [{ "Effect": "Allow", "Principal": {"Service": "lambda.amazonaws.com"}, "Action": "sts:AssumeRole"}]}'
aws iam attach-role-policy --role-name flyway-lambda-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Then deploy the lambda to the same VPC your RDS resides on (using the private subnets) and the RDS security group
aws lambda create-function --function-name flyway-lambda \
--zip-file fileb://flyway-all.jar --handler com.geekoosh.flyway.FlywayHandler::handleRequest --runtime java8 \
--role arn:aws:iam::123456789012:role/flyway-lambda-role \
--vpc-config SubnetIds=PrivateSubnet1,PrivateSubnet2,SecurityGroupIds=RDSSecurityGroupId \
--memory-size 512 --timeout 60 \
--environment Variables={GIT_REPOSITORY=https://gitprovider/gitrepo.git,DB_CONNECTION_STRING=https://myrds/endpoint}
Note: we are overriding the defaults to a higher memory limit of 512GB and a longer timeout period of 60 seconds.