Created
January 29, 2019 00:07
-
-
Save skierkowski/eb7a43ba6e18d39e5773efb17abb178f to your computer and use it in GitHub Desktop.
Serverless Framework Enterprise Safeguard Policies
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
const { fromPairs } = require('lodash') | |
module.exports = function requireFunctionDescription(policy, service, options) { | |
const { | |
declaration: { functions }, | |
provider: { naming }, | |
compiled: { | |
'cloudformation-template-update-stack.json': { Resources } | |
} | |
} = service | |
const logicalFuncNamesToConfigFuncName = fromPairs( | |
Object.keys(functions || {}).map((funcName) => [naming.getLambdaLogicalId(funcName), funcName]) | |
) | |
for (const [funcName, { Properties, Type}] of Object.entries(Resources)) { | |
if (Type !== 'AWS::Lambda::Function') { | |
continue | |
} | |
if (!Properties.Description) { | |
const configFuncName = logicalFuncNamesToConfigFuncName[funcName] || funcName | |
policy.warn ( | |
`Description on function '${configFuncName}' is missing` | |
) | |
} | |
} | |
policy.approve() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment