mapbox / cloudfriend

Helper functions for assembling CloudFormation templates in JavaScript
ISC License
69 stars 9 forks source link

making hookshot inline code compatible with aws-sdk-v3 #141

Closed bilindhajer closed 1 year ago

bilindhajer commented 1 year ago

node runtimes 18 and higher will now come prepackaged with aws sdk v3, and no longer aws sdk v2. The Hookshot lambdas use inline code that use aws sdk v2, while this was okay with node versions <= 16, this will now break with node18.x runtimes. This means that our latest release 7.0.0 creates incompatible hookshot lambdas, unless user passes in a lower node version. Note the runtimes for the hookshot lambdas take the current default lambda runtime which is now nodejs18.x.

This PR addresses this by,

  1. Uses aws sdk v3 modules for inline code.
  2. if user does pass in the lambda runtime, asserts that it is >= nodejs18.x.
  3. Additional change for aws sdk v3 that had to be reflected in the inline code, is the lambda response payload now returns a byte array instead of a string, so I am decoding to string before parsing to Json in the webhook lambda that invokes the lambda the user passes in.

My initial approach was to have inline code be aws-sdk v2 compatible if user passes in a lower node version, but this is inline code so we should control the runtime. Otherwise we have to maintain two different inline code versions which is more difficult to maintain and doesn't really make sense since this shortcut does not advertise to pass in the node version.

This will be released as a patch to version 7.0.0. This has been tested internally and working.