Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement