-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.js
31 lines (25 loc) · 874 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const getPathFromArgs = (args) => {
if (!args || args.length !== 3)
throw new Error("You must specify a path")
const [path] = args.slice(2)
return path
}
const isStateMachineResource = (resource) => {
const STATE_MACHINE_RESOURCE_TYE = 'AWS::StepFunctions::StateMachine';
if (!resource.hasOwnProperty('Type'))
return false;
return resource.Type === STATE_MACHINE_RESOURCE_TYE
}
const createResourceArray = (cfnStackJson, condition) => {
if (!cfnStackJson.hasOwnProperty('Resources'))
throw new Error("Missing 'Resources' property")
const {Resources: resources} = cfnStackJson;
return Object.keys(resources)
.filter(resource => condition(resources[resource]))
.map(resource => resources[resource])
}
module.exports = {
getPathFromArgs,
isStateMachineResource,
createResourceArray
}