Publish Lambda Layers across Regions

This could even be classified as re:Inventing the wheel but was a quick hack workaround that I found at the early stages where we required a set of node.js libraries and custom modules across multiple regions, in fact, I needed this in only 5 regions. Since these libraries and modules could have frequent updates, I wanted the latest package to be updated and published as a new layer version to each region and concerned developers be notified about the new layer version as well as the changelog. Well, to make the long story short, I was at that time familiar with subversion, and the project code was committed to an svn repository. This could have biased me to use the following solution at that time period, rather now my preference would be either “Multi-Region Deployment” using cloud formation or “CodeCommit and CodePipeline with SNS” instead of S3 triggers.

The architecture is simple and was deployed manually at that time. Sorry to say that I no longer have any access to the aws account, as it is a discarded community project and the account is closed at this time. Thought about posting the idea over here since there was a discussion or rather query about this in a community forum.

Nothing complicated, as one would know the subversion post-commit hook would trigger a shell-based deployment when the commit comment has a keyword (deploy). Which would go through the basic code security roundup, lint checks on the custom modules, do an npm install on the top folder, rearrange some things here and there, create a zip deployment to a preset s3 bucket. The s3:ObjectCreated:* event would trigger a lambda, which will create a signed payload and publish it to a named topic (SNS). The payload signature was a simple md5 checksum with an added keyword to the payload data. This keyword was used at all the other regional lambda to validate the payload request. Each lambda deployed in the other regions had a subscription to the named topic (SNS). The lambda further uses publishLayerVersion of the AWS Javascript SDK to publish the new layer code. And on success post a message to another SNS topic such that the consumers can be informed about the update.