Don't assume a Parameter value is a str

Currently show_stack and list_stacks will fail for templates
which have a Number in the Parameters.

This should be considered for backport to milestone_proposed.

Change-Id: I1b20babf0998f7714f8bc7bf144e03ff1d7c0c91
Fixes: bug #1160653
(cherry picked from commit b76eb46fde)
This commit is contained in:
Steve Baker 2013-03-27 13:35:54 +13:00 committed by Thierry Carrez
parent 1ac1f89513
commit e726084594
2 changed files with 15 additions and 1 deletions

View File

@ -120,7 +120,7 @@ class Parameter(object):
if self.no_echo():
return '******'
else:
return value
return str(value)
class NumberParam(Parameter):

View File

@ -329,3 +329,17 @@ class ParametersTest(unittest.TestCase):
'AWS::StackName': True}
self.assertEqual(params.map(lambda p: p.has_default()), expected)
def test_map_str(self):
template = {'Parameters': {'Foo': {'Type': 'String'},
'Bar': {'Type': 'Number'}}}
params = parameters.Parameters('test_params', template, {
'Foo': 'foo', 'Bar': 42})
expected = {'Foo': 'foo',
'Bar': '42',
'AWS::Region': 'ap-southeast-1',
'AWS::StackId': 'None',
'AWS::StackName': 'test_params'}
self.assertEqual(params.map(str), expected)