Skip to content

Commit 3a3326f

Browse files
authored
Merge pull request #540 from acmcelwee/amc-fix-diff
Fix parameter handling for diffs
2 parents 2eafbaa + 2cc8fcc commit 3a3326f

4 files changed

Lines changed: 45 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
3+
- (bugfix) Fix parameter handling for diffs [GH-540]
4+
15
## 1.2.0rc1 (2018-02-15)
26

37
The biggest change in this release has to do with how we build the graph

stacker/actions/diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ def _diff_stack(self, stack, **kwargs):
215215

216216
stack.resolve(self.context, self.provider)
217217
# generate our own template & params
218-
new_template = stack.blueprint.to_json()
219218
parameters = self.build_parameters(stack)
220219
new_params = dict()
221220
for p in parameters:
222221
new_params[p['ParameterKey']] = p['ParameterValue']
222+
new_template = stack.blueprint.rendered
223223
new_stack = self._normalize_json(new_template)
224224

225225
print "============== Stack: %s ==============" % (stack.name,)

stacker/tests/fixtures/mock_blueprints.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,23 @@ def create_template(self):
214214
self.template.add_resource(WaitConditionHandle("VPC"))
215215

216216

217+
class DiffTester(Blueprint):
218+
VARIABLES = {
219+
"InstanceType": {
220+
"type": CFNString,
221+
"description": "NAT EC2 instance type.",
222+
"default": "m3.medium"},
223+
"WaitConditionCount": {
224+
"type": int,
225+
"description": "Number of WaitConditionHandle resources "
226+
"to add to the template"}
227+
}
228+
229+
def create_template(self):
230+
for i in range(self.get_variables()["WaitConditionCount"]):
231+
self.template.add_resource(WaitConditionHandle("VPC%d" % i))
232+
233+
217234
class Bastion(Blueprint):
218235
VARIABLES = {
219236
"VpcId": {"type": EC2VPCId, "description": "Vpc Id"},

tests/suite.bats

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,29 +317,44 @@ EOF
317317
@test "stacker diff - simple diff with output lookups" {
318318
needs_aws
319319

320-
config() {
320+
config1() {
321321
cat <<EOF
322322
namespace: ${STACKER_NAMESPACE}
323323
stacks:
324324
- name: vpc
325-
class_path: stacker.tests.fixtures.mock_blueprints.Dummy
326-
- name: bastion
327-
class_path: stacker.tests.fixtures.mock_blueprints.Dummy
325+
class_path: stacker.tests.fixtures.mock_blueprints.DiffTester
328326
variables:
329-
StringVariable: \${output vpc::DummyId}
327+
InstanceType: m3.large
328+
WaitConditionCount: 1
329+
EOF
330+
}
331+
332+
config2() {
333+
cat <<EOF
334+
namespace: ${STACKER_NAMESPACE}
335+
stacks:
336+
- name: vpc
337+
class_path: stacker.tests.fixtures.mock_blueprints.DiffTester
338+
variables:
339+
InstanceType: m3.xlarge
340+
WaitConditionCount: 2
330341
EOF
331342
}
332343

333344
teardown() {
334-
stacker destroy --force <(config)
345+
stacker destroy --force <(config1)
335346
}
336347

337348
# Create the new stacks.
338-
stacker build <(config)
349+
stacker build <(config1)
339350
assert "$status" -eq 0
340351

341-
stacker diff <(config)
352+
stacker diff <(config2)
342353
assert "$status" -eq 0
354+
assert_has_line "\-InstanceType = m3.large"
355+
assert_has_line "+InstanceType = m3.xlarge"
356+
assert_has_line "+ \"VPC1\": {"
357+
assert_has_line "+ \"Type\": \"AWS::CloudFormation::WaitConditionHandle\""
343358
}
344359

345360
@test "stacker build - replacements-only test with additional resource, no keyerror" {

0 commit comments

Comments
 (0)