Skip to content

Commit 95a5fac

Browse files
fix(local-image-aws-creds): use short lived creds
1 parent e2f3888 commit 95a5fac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/sagemaker/local/image.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def _aws_credentials(session):
10141014
"AWS_ACCESS_KEY_ID=%s" % (str(access_key)),
10151015
"AWS_SECRET_ACCESS_KEY=%s" % (str(secret_key)),
10161016
]
1017-
if not _aws_credentials_available_in_metadata_service():
1017+
if _use_short_lived_credentials() or not _aws_credentials_available_in_metadata_service():
10181018
logger.warning(
10191019
"Using the short-lived AWS credentials found in session. They might expire while "
10201020
"running."
@@ -1052,6 +1052,10 @@ def _aws_credentials_available_in_metadata_service():
10521052
return not instance_metadata_provider.load() is None
10531053

10541054

1055+
def _use_short_lived_credentials():
1056+
return os.environ.get("USE_SHORT_LIVED_CREDENTIALS") == "1"
1057+
1058+
10551059
def _write_json_file(filename, content):
10561060
"""Write the contents dict as json to the file.
10571061

0 commit comments

Comments
 (0)