From 506a30cf3eedca0724e97d6edbf9e0d100194e4b Mon Sep 17 00:00:00 2001 From: mikedlr Date: Fri, 1 Sep 2017 14:25:54 +0100 Subject: [PATCH] lambda - more limited exception trap when doing get_function for better errors (#28918) --- lib/ansible/modules/cloud/amazon/lambda.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/lambda.py b/lib/ansible/modules/cloud/amazon/lambda.py index 576781cf86a..2084fd88b1c 100644 --- a/lib/ansible/modules/cloud/amazon/lambda.py +++ b/lib/ansible/modules/cloud/amazon/lambda.py @@ -238,8 +238,13 @@ def get_current_function(connection, function_name, qualifier=None): if qualifier is not None: return connection.get_function(FunctionName=function_name, Qualifier=qualifier) return connection.get_function(FunctionName=function_name) - except ClientError: - return None + except ClientError as e: + try: + if e.response['Error']['Code'] == 'ResourceNotFoundException': + return None + except (KeyError, AttributeError): + pass + raise e def sha256sum(filename):