diff --git a/heat/engine/resources/random_string.py b/heat/engine/resources/random_string.py index c5808b820..65f381e1a 100644 --- a/heat/engine/resources/random_string.py +++ b/heat/engine/resources/random_string.py @@ -63,7 +63,8 @@ class RandomString(resource.Resource): } attributes_schema = { - 'value': _('The random string generated by this resource'), + 'value': _('The random string generated by this resource. This value ' + 'is also available by referencing the resource.'), } _sequences = { @@ -86,6 +87,7 @@ class RandomString(resource.Resource): sequence = self._sequences[self.properties.get(self.SEQUENCE)] random_string = self._generate_random_string(sequence, length) db_api.resource_data_set(self, 'value', random_string, redact=True) + self.resource_id_set(random_string) def _resolve_attribute(self, name): if name == 'value': diff --git a/heat/tests/test_random_string.py b/heat/tests/test_random_string.py index dbb8357cb..2b1927505 100644 --- a/heat/tests/test_random_string.py +++ b/heat/tests/test_random_string.py @@ -70,14 +70,17 @@ Resources: self.assertThat(random_string, MatchesRegex('[a-zA-Z0-9]{32}')) self.assertRaises(exception.InvalidTemplateAttribute, secret1.FnGetAtt, 'foo') + self.assertEqual(random_string, secret1.FnGetRefId()) secret2 = stack['secret2'] random_string = secret2.FnGetAtt('value') self.assertThat(random_string, MatchesRegex('[a-zA-Z0-9]{10}')) + self.assertEqual(random_string, secret2.FnGetRefId()) secret3 = stack['secret3'] random_string = secret3.FnGetAtt('value') self.assertThat(random_string, MatchesRegex('[0-7]{100}')) + self.assertEqual(random_string, secret3.FnGetRefId()) class TestGenerateRandomString(HeatTestCase):