serverless-plugin-additional-stacks
Advanced tools
Comparing version 1.4.0 to 1.5.0
32
index.js
'use strict' | ||
const path = require('path') | ||
const merge = require('lodash.merge') | ||
@@ -99,4 +100,25 @@ class AdditionalStacksPlugin { | ||
mergeAdditionalStacks() { | ||
// For each key in the additionalStacks, check if it's an array or not. | ||
// If it is an array, merge the keys together. Else, return the original value. | ||
return Object.fromEntries(Object.entries(this.serverless.service.custom.additionalStacks).map(([k, v], i) => { | ||
if (Array.isArray(v)) { | ||
return [k, v.reduce((memo, value) => { | ||
if (value) { | ||
if (typeof value === 'object') { | ||
return merge(memo, value); | ||
} | ||
throw new Error(`Non-object value specified in ${key} array: ${value}`); | ||
} | ||
return memo; | ||
}, {})]; | ||
} else { | ||
return [k, v]; | ||
} | ||
})); | ||
} | ||
getAdditionalStacks() { | ||
return this.serverless.service.custom && this.serverless.service.custom.additionalStacks || {} | ||
return (this.serverless.service.custom && this.serverless.service.custom.additionalStacks && this.mergeAdditionalStacks()) || {} | ||
} | ||
@@ -337,2 +359,6 @@ | ||
} | ||
// If the CloudFormation Template has the Transform tag, an additional capability is needed. | ||
if (compiledCloudFormationTemplate.Transform) { | ||
params.Capabilities.push("CAPABILITY_AUTO_EXPAND") | ||
} | ||
@@ -375,2 +401,6 @@ this.serverless.cli.log('Creating additional stack ' + stackName + '...') | ||
} | ||
// If the CloudFormation Template has the Transform tag, an additional capability is needed. | ||
if (compiledCloudFormationTemplate.Transform) { | ||
params.Capabilities.push("CAPABILITY_AUTO_EXPAND") | ||
} | ||
@@ -377,0 +407,0 @@ return this.provider.request( |
{ | ||
"name": "serverless-plugin-additional-stacks", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"main": "index.js", | ||
@@ -9,3 +9,6 @@ "repository": {}, | ||
"test": "cd test && npm run test" | ||
}, | ||
"dependencies": { | ||
"lodash.merge": "^4.6.2" | ||
} | ||
} |
@@ -18,2 +18,9 @@ 'use strict' | ||
// set region if not set (as not set by the SDK by default) | ||
if (!AWS.config.region) { | ||
AWS.config.update({ | ||
region: 'us-east-1' | ||
}); | ||
} | ||
const cloudformation = new AWS.CloudFormation() | ||
@@ -29,2 +36,4 @@ chai.use(chaiAsPromised) | ||
const SECONDARY_STACK_FULLNAME = 'additional-stacks-plugin-service-test-customname-secondary' | ||
const TERTIARY_STACK = 'tertiary' | ||
const TERTIARY_STACK_FULLNAME = 'additional-stacks-plugin-service-test-customname-tertiary' | ||
@@ -100,2 +109,3 @@ function sls(args) { | ||
describeStack(SECONDARY_STACK_FULLNAME), | ||
describeStack(TERTIARY_STACK_FULLNAME), | ||
]) | ||
@@ -122,2 +132,5 @@ } | ||
}) | ||
.then(() => { | ||
return deleteStack(TERTIARY_STACK_FULLNAME) | ||
}) | ||
} | ||
@@ -143,8 +156,11 @@ | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[0].StackStatus, 'UPDATE_COMPLETE', 'serverless stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
assert.equal(responses[0].Tags.filter(tag => tag.Key === 'Owner')[0].Value, 'owner@example.org', 'serverless stack custom tag') | ||
assert.equal(responses[1].Tags.filter(tag => tag.Key === 'Owner')[0].Value, 'owner@example.org', 'primary stack custom tag') | ||
assert.equal(responses[2].Tags.filter(tag => tag.Key === 'Owner')[0].Value, 'another@example.org', 'secondary stack custom tag') | ||
assert.equal(responses[3].Tags.filter(tag => tag.Key === 'Owner')[0].Value, 'yetanother@example.org', 'tertiary stack custom tag') | ||
}) | ||
@@ -165,5 +181,7 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[0].StackStatus, 'UPDATE_COMPLETE', 'serverless stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
}) | ||
@@ -185,5 +203,7 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[0].StackStatus, 'UPDATE_COMPLETE', 'serverless stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'UPDATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
}) | ||
@@ -204,4 +224,6 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'UPDATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
}) | ||
@@ -229,4 +251,6 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
}) | ||
@@ -247,4 +271,6 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
}) | ||
@@ -266,4 +292,6 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.isOk(responses[3], 'tertiary stack') | ||
assert.equal(responses[1].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'UPDATE_COMPLETE', 'secondary stack') | ||
assert.equal(responses[3].StackStatus, 'CREATE_COMPLETE', 'tertiary stack') | ||
}) | ||
@@ -288,2 +316,3 @@ }) | ||
assert.isNull(responses[2], 'secondary stack') | ||
assert.isNull(responses[3], 'tertiary stack') | ||
assert.equal(responses[0].StackStatus, 'UPDATE_COMPLETE', 'serverless stack') | ||
@@ -312,3 +341,4 @@ }) | ||
assert.isOk(responses[2], 'secondary stack') | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'primary stack') | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'secondary stack') | ||
assert.isNull(responses[3], 'tertiary stack') | ||
}) | ||
@@ -330,2 +360,3 @@ }) | ||
assert.equal(responses[2].StackStatus, 'CREATE_COMPLETE', 'secondary stack') | ||
assert.isNull(responses[3], 'tertiary stack') | ||
}) | ||
@@ -347,2 +378,3 @@ }) | ||
assert.equal(responses[2].StackStatus, 'UPDATE_COMPLETE', 'secondary stack') | ||
assert.isNull(responses[3], 'tertiary stack') | ||
}) | ||
@@ -363,2 +395,3 @@ }) | ||
assert.isNull(responses[2], 'secondary stack') | ||
assert.isNull(responses[3], 'tertiary stack') | ||
}) | ||
@@ -365,0 +398,0 @@ }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
80065
14
855
1
1
+ Addedlodash.merge@^4.6.2
+ Addedlodash.merge@4.6.2(transitive)