Skip to content

Commit 8d70169

Browse files
authored
Merge pull request #9 from baptiste-s/patch-2
[issue-8] add support for ssm parameter with value starting with ami-
2 parents dc75191 + 2866f00 commit 8d70169

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

functions/lambda.py

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

6060
def get_current_image_id():
6161
"""Returns current AMI from SSM"""
62+
param_value = None
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+
value = param['Parameter']['Value']
65+
if value.startswith('ami-'):
66+
image_id = value
67+
else:
68+
param_value = json.loads(value)
69+
image_id = param_value['image_id']
6570
logger.info('Newest image_id is "%s"', image_id)
66-
return param_value['image_id']
71+
return image_id
6772

6873

6974
def get_launch_template_name_and_auto_scaling_group():

0 commit comments

Comments
 (0)