Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to use previous value for parameters #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/createChangeSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const _ = require('lodash')

const createChangeSet = (plugin, stackName, changeSetName, changeSetType) => {
const compiledTemplate = plugin.serverless.service.provider.compiledCloudFormationTemplate || {}
const compiledTemplateFileName = 'compiled-cloudformation-template.json'
const templateUrl = `https://s3.amazonaws.com/${plugin.bucketName}/${plugin.serverless.service.package.artifactDirectoryName}/${compiledTemplateFileName}`

Expand All @@ -22,7 +23,10 @@ const createChangeSet = (plugin, stackName, changeSetName, changeSetType) => {
'CAPABILITY_NAMED_IAM'
],
ChangeSetType: changeSetType,
Parameters: [],
Parameters: Object.keys(compiledTemplate.Parameters || {}).map(key => ({
ParameterKey: key,
UsePreviousValue: true
})),
TemplateURL: templateUrl,
Tags: Object.keys(stackTags).map((key) => ({
Key: key,
Expand Down
17 changes: 17 additions & 0 deletions lib/createChangeSet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,22 @@ describe('updateStack', () => {
)
})
})

it('should use previous value for parameters', () => {
serverlessChangeSets.serverless.service.provider.compiledCloudFormationTemplate = {
Parameters: {
param1: {},
param2: {}
}
}

return createChangeSet.bind(serverlessChangeSets)().then(() => {
expect(createChangeSetStub.args[0][2].Parameters)
.to.deep.equal([
{ ParameterKey: 'param1', UsePreviousValue: true },
{ ParameterKey: 'param2', UsePreviousValue: true }
])
})
})
})
})