diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py index 5356ee51da..241fd9c49d 100644 --- a/heat/engine/hot/functions.py +++ b/heat/engine/hot/functions.py @@ -80,6 +80,14 @@ class GetParam(function.Function): raise TypeError(_('Path components in "%s" ' 'must be strings') % self.fn_name) + if isinstance(collection, collections.Sequence + ) and isinstance(key, six.string_types): + try: + key = int(key) + except ValueError: + raise TypeError(_("Path components in '%s' " + "must be a integer " + "parsable strings.") % self.fn_name) return collection[key] try: diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index d12378ce67..06b3bc370e 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -1661,6 +1661,10 @@ class StackParametersTest(common.HeatTestCase): dict(params={'list': 'foo,bar'}, snippet={'properties': {'prop1': {'get_param': ['list', 1]}}}, expected={'properties': {'prop1': 'bar'}})), + ('get_list_attr_string_index', + dict(params={'list': 'foo,bar'}, + snippet={'properties': {'prop1': {'get_param': ['list', '1']}}}, + expected={'properties': {'prop1': 'bar'}})), ('get_flat_dict_attr', dict(params={'flat_dict': {'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}},