UNCLASSIFIED

Commit 80e531f3 authored by Tim Seagren's avatar Tim Seagren
Browse files

adding accessdeniedexception hnadling

parent 8e5db8eb
...@@ -71,10 +71,15 @@ def _store_new_password(client, secret_name, username, password, old_password): ...@@ -71,10 +71,15 @@ def _store_new_password(client, secret_name, username, password, old_password):
# We can't find the resource that you asked for. # We can't find the resource that you asked for.
# Deal with the exception here, and/or rethrow at your discretion. # Deal with the exception here, and/or rethrow at your discretion.
raise e raise e
elif e.response['Error']['Code'] == 'AccessDeniedException':
# We can't find the resource that you asked for.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
def _get_credential(client, secret_name): def _get_credential(client, secret_name):
logs.info(f"Getting credential {secret_name}")
try: try:
get_secret_value_response = client.get_secret_value( get_secret_value_response = client.get_secret_value(
SecretId=secret_name SecretId=secret_name
...@@ -100,7 +105,12 @@ def _get_credential(client, secret_name): ...@@ -100,7 +105,12 @@ def _get_credential(client, secret_name):
# We can't find the resource that you asked for. # We can't find the resource that you asked for.
# Deal with the exception here, and/or rethrow at your discretion. # Deal with the exception here, and/or rethrow at your discretion.
raise e raise e
elif e.response['Error']['Code'] == 'AccessDeniedException':
# We can't find the resource that you asked for.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
else: else:
logs.info(f"Found secret {secret_name}")
# Decrypts secret using the associated KMS CMK. # Decrypts secret using the associated KMS CMK.
# Depending on whether the secret is a string or binary, one of these fields will be populated. # Depending on whether the secret is a string or binary, one of these fields will be populated.
if 'SecretString' in get_secret_value_response: if 'SecretString' in get_secret_value_response:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment