NOTE: This repo contains only the documentation for the private BoltsOps Pro repo code. Original file: https://github.com/boltopspro/lambda/blob/master/README.md The docs are publish so they are available for interested customers. For access to the source code, you must be a paying BoltOps Pro subscriber. If are interested, you can contact us at contact@boltops.com or https://www.boltops.com
This blueprint provisions a Lambda Function and CloudWatch Event Rule. The example does the heavy lifting by providing some good code structure. It can be uses an an example to to be modified and fit your needs.
- Includes an example of Lambda Layer
- Includes necessary Lambda Permission and IAM Role
- Optionally supports VpcConfig. Variables can be used to set different values for multiple environments.
- Supports Lambda X-Ray tracing
- Can customize ScheduledExpression or EventPattern.
- Add blueprint to Gemfile
- Configure: configs/lambda values
- Deploy blueprint
Add the blueprint to your lono project's Gemfile
.
gem "lambda", git: "git@github.com:boltopspro/lambda.git"
Use the lono seed command to generate a starter config params files.
LONO_ENV=development lono seed lambda
LONO_ENV=production lono seed lambda
The files in config/lambda
folder will look something like this:
configs/lambda/
└── variables
├── development.rb
└── production.rb
Configure the configs/lambda/variables
files.
Use the lono cfn deploy command to deploy.
LONO_ENV=development lono cfn deploy lambda --sure --no-wait
LONO_ENV=production lono cfn deploy lambda --sure --no-wait
If you are using One AWS Account, use these commands instead: One Account.
The default Lambda Runtime for this blueprint is ruby2.7
. You can adjust this with the @lambda_runtime
variable.
@lambda_runtime = "ruby2.5"
IMPORTANT: Make sure that the version of ruby you are using matches. Lono uses your ruby version to build the autmoatically build the Lambda Layer. To check your ruby version:
$ ruby -v
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
$
Make sure to run lono clean also if you are changing ruby versions as the lambda layer could be cached in output.
lono clean
If you change the @lambda_runtime
to other languages, you'll need to change the code also: app/files/lambda-function. You will also need to handle building and adding the files for the Lambda Layer.
With ruby2.5 when the json
is in your Gemfile it confuses ruby and it is unable to require json. Believe this is a bug in ruby2.5 itself. Either remove json from your Gemfile or use the ruby2.7 runtime.
Refer to the lono lambda extension for details on how to configure the Schedule Expression, VPC, X-Ray Tracing, etc.