Skip to content

Commit

Permalink
Updated execute lambda module to wait for Lambda function to be active
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Jonsson committed Jan 28, 2022
1 parent b595db6 commit 177ed81
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plugins/modules/execute_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ def main():
elif name:
invoke_params['FunctionName'] = name

if not module.check_mode:
wait_for_lambda(client, module, name)

try:
response = client.invoke(**invoke_params)
except is_boto3_error_code('ResourceNotFoundException') as nfe:
Expand Down Expand Up @@ -255,5 +258,15 @@ def main():
module.exit_json(changed=True, result=results)


def wait_for_lambda(client, module, name):
try:
waiter = client.get_waiter('function_active')
waiter.wait(FunctionName=name)
except botocore.exceptions.WaiterError as e:
module.fail_json_aws(e, msg='Timeout while waiting on lambda to be Active')
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg='Failed while waiting on lambda to be Active')


if __name__ == '__main__':
main()

0 comments on commit 177ed81

Please sign in to comment.