Created
September 10, 2019 21:06
-
-
Save brianleroux/f10f88089a7e85d3976279e94a90ef8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fixes begin/data for architect 6.x apps | |
*/ | |
module.exports = function beginDataMacro(arc, cfn) { | |
if (!cfn.Resources.DataTable) { | |
// adds a dynamodb table for begin/data if @tables is missing 'data' | |
// adds a CRUD policy to Role for data table | |
} | |
let lambdas = Object.keys(cfn.Resources).filter(function isLambda(Name) { | |
let resource = cfn.Resources[Name] | |
return resource.Type === 'AWS::Serverless::Function' || resource.Type === 'AWS::Lambda::Function' | |
}) | |
// adds BEGIN_DATA_TABLE_NAME env var to all Lambdas | |
lambdas.forEach(Lambda=> { | |
let env = cfn.Resources[Lambda].Properties.Environment.Variables | |
env.BEGIN_DATA_TABLE_NAME = {Ref: 'DataTable'} | |
}) | |
return cfn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment