Skip to content

Commit 2601832

Browse files
authored
[issue-8] add support for ssm parameter with value starting with ami-
1 parent 7e299cf commit 2601832

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

functions/lambda.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ class InstanceRefreshInProgress(LambdaError):
5959

6060
def get_current_image_id():
6161
"""Returns current AMI from SSM"""
62+
param_value = ""
6263
param = ssm.get_parameter(Name=SSM_PARAMETER_NAME)
63-
param_value = json.loads(param['Parameter']['Value'])
64-
image_id = param_value['image_id']
64+
if param['Parameter']['Value'].startswith('ami-'):
65+
image_id = param['Parameter']['Value']
66+
else:
67+
param_value = json.loads(param['Parameter']['Value'])
68+
image_id = param_value['image_id']
6569
logger.info('Newest image_id is "%s"', image_id)
66-
return param_value['image_id']
70+
return image_id
6771

6872

6973
def get_launch_template_name_and_auto_scaling_group():

0 commit comments

Comments
 (0)