Handle edge case where you can end up with double dashes in target group names
This commit is contained in:
parent
81381cd035
commit
eb018c01a5
@ -252,6 +252,10 @@ def generate_resource_name(resource_type, stack_name, logical_id):
|
||||
name_prefix = '{0}-{1}'.format(stack_name, logical_id)
|
||||
my_random_suffix = random_suffix()
|
||||
truncated_name_prefix = name_prefix[0:32 - (len(my_random_suffix) + 1)]
|
||||
# if the truncated name ends in a dash, we'll end up with a double dash in the final name, which is
|
||||
# not allowed
|
||||
if truncated_name_prefix.endswith('-'):
|
||||
truncated_name_prefix = truncated_name_prefix[:-1]
|
||||
return '{0}-{1}'.format(truncated_name_prefix, my_random_suffix)
|
||||
else:
|
||||
return '{0}-{1}-{2}'.format(stack_name, logical_id, random_suffix())
|
||||
|
@ -1584,5 +1584,5 @@ def test_create_target_groups_through_cloudformation():
|
||||
# and one named MyTargetGroup
|
||||
assert len([tg for tg in target_group_dicts if tg['TargetGroupName'] == 'MyTargetGroup']) == 1
|
||||
assert len(
|
||||
[tg for tg in target_group_dicts if tg['TargetGroupName'].startswith('test-stack-test')]
|
||||
[tg for tg in target_group_dicts if tg['TargetGroupName'].startswith('test-stack')]
|
||||
) == 2
|
||||
|
Loading…
Reference in New Issue
Block a user