As part of the telegraf, we have a bot called the telegraf-tiger. The bot is made up of a number of AWS Lambda functions to do various actions for us. For example, it can auto-label new issues, close old issues, share build, artifcts on PRs, and more.
These lambda functions were originally set up to run on the go1.x runtime as the functions themselves are all small Go scripts. However, AWS announced that the go1.x runtime is deprecated and users should migrate to the custom runtime on Amazon Linux 2 instead.
The following is an outline of the changes I made to migrate our existing functions over.
Serverless Link to heading
The deployments use serverless to deploy our functions, and this was fairly easy set of changes, once you knew what was needed:
- For the provider, set
- For the package, switched from patterns to the
individually: truesetting. Each function will specify a specific artifact.
- For each function, set
handler: bootstrapand added the
package.artifactoption which points to the zip artifact
Essentially I switched the run time, and then switched the packages from a pattern to instead point to a zip file with the lambda artifact.
An example service looks like:
Builds Link to heading
Our previous builds of the lambda binaries produced a folder with a binary for each function. The current build for each lambda involves a build then archiving the binary in the root of that archive:
As a part of this change, I took the opportunity to ensure the builds are specific to amd64, given the architecture mentioned above, and set the tag to remove the RPC dependency for an even smaller binary.
Deployment Link to heading
Once I redeployed the changes took effect immediately and I could see in the Lambda functions list the runtime get updated to “Custom runtime on Amazon Linux 2”.
References Link to heading
I found the following very helpful during the migration: