Skip to content

Commit

Permalink
Merge pull request #9 from baptiste-s/patch-2
Browse files Browse the repository at this point in the history
[issue-8] add support for ssm parameter with value starting with ami-
  • Loading branch information
radimsuckr authored Apr 1, 2022
2 parents dc75191 + 2866f00 commit 8d70169
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions functions/lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ class InstanceRefreshInProgress(LambdaError):

def get_current_image_id():
"""Returns current AMI from SSM"""
param_value = None
param = ssm.get_parameter(Name=SSM_PARAMETER_NAME)
param_value = json.loads(param['Parameter']['Value'])
image_id = param_value['image_id']
value = param['Parameter']['Value']
if value.startswith('ami-'):
image_id = value
else:
param_value = json.loads(value)
image_id = param_value['image_id']
logger.info('Newest image_id is "%s"', image_id)
return param_value['image_id']
return image_id


def get_launch_template_name_and_auto_scaling_group():
Expand Down

0 comments on commit 8d70169

Please sign in to comment.