UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Ironbank Tools
administration-tools
Commits
80e531f3
Commit
80e531f3
authored
Jul 26, 2021
by
Tim Seagren
Browse files
adding accessdeniedexception hnadling
parent
8e5db8eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
rotate-credentials/rotate-credentials.py
rotate-credentials/rotate-credentials.py
+10
-0
No files found.
rotate-credentials/rotate-credentials.py
View file @
80e531f3
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment