SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * fixes begin/data for architect 6.x apps
  3.  */
  4. module.exports = function beginDataMacro(arc, cfn) {
  5.   if (!cfn.Resources.DataTable) {
  6.     // adds a dynamodb table for begin/data if @tables is missing 'data'
  7.     // adds a CRUD policy to Role for data table
  8.   }
  9.   let lambdas = Object.keys(cfn.Resources).filter(function isLambda(Name) {
  10.     let resource = cfn.Resources[Name]
  11.     return resource.Type === 'AWS::Serverless::Function' || resource.Type === 'AWS::Lambda::Function'
  12.   })
  13.   // adds BEGIN_DATA_TABLE_NAME env var to all Lambdas
  14.   lambdas.forEach(Lambda=> {
  15.     let env = cfn.Resources[Lambda].Properties.Environment.Variables
  16.     env.BEGIN_DATA_TABLE_NAME = {Ref: 'DataTable'}
  17.   })
  18.   return cfn
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top