lambda update for get function and broken error handling in ec2
This commit is contained in:
@@ -85,3 +85,36 @@ def list_event_source_mappings():
|
||||
print("Unexpected error: {}" .format(e))
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def lambda_get_function(functionname, region):
|
||||
'''
|
||||
Returns the configuration information of the Lambda function and a presigned URL link to the .zip file you uploaded with CreateFunction so you can download the .zip file. Note that the URL is valid for up to 10 minutes. The configuration information is the same information you provided as parameters when uploading the function.
|
||||
'''
|
||||
print("### Attempting to get function {} ###".format(functionname))
|
||||
try:
|
||||
client = boto3.client('lambda', region_name=region)
|
||||
|
||||
response = client.get_function(FunctionName=functionname)
|
||||
#print(response)
|
||||
|
||||
if response.get('Configuration') is None:
|
||||
print("{} likely does not have Lambda permissions\n" .format(AWS_ACCESS_KEY_ID))
|
||||
elif len(response['Configuration']) <= 0:
|
||||
print("[-] GetFunction allowed for {} but no results [-]" .format(region))
|
||||
else:
|
||||
print(response['Configuration'])
|
||||
print("\n")
|
||||
# print(response['Code'])
|
||||
print("Download link for {}:{}".format(functionname,response['Code']['Location']))
|
||||
except botocore.exceptions.ClientError as e:
|
||||
if e.response['Error']['Code'] == 'InvalidClientTokenId':
|
||||
sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
|
||||
elif e.response['Error']['Code'] == 'AccessDenied':
|
||||
print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID))
|
||||
elif e.response['Error']['Code'] == 'SubscriptionRequiredException':
|
||||
print('{} : Has permissions but isnt signed up for service - usually means you have a root account' .format(AWS_ACCESS_KEY_ID))
|
||||
else:
|
||||
print("Unexpected error: {}" .format(e))
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
Reference in New Issue
Block a user