Files
pytorch/.github/scripts/get_aws_session_tokens.py
Nikita Shulga c7a65f58b0 [CI] Script to fetch creds from current AWS session (#121426)
Because some implementations, like OpenDAL does not work with AWS IMDSv2, but this script will bridge the gap and enables more recent `sccache` releases(that switched from simple-s3 to OpenDAL) to work in current CI system

When launched it prints something like:
```
export AWS_ACCESS_KEY_ID=XXXXX
export AWS_SECRET_ACCESS_KEY=YYYY
export AWS_SESSION_TOKEN=ZZZZ
```
which can be `eval`ed and passed then sccache can use those failures.

Validated in https://github.com/pytorch/pytorch/pull/121323
Pull Request resolved: https://github.com/pytorch/pytorch/pull/121426
Approved by: https://github.com/Skylion007
2024-03-07 19:25:54 +00:00

14 lines
405 B
Python
Executable File

#!/usr/bin/env python3
import boto3 # type: ignore[import]
def main() -> None:
creds_dict = boto3.Session().get_credentials().get_frozen_credentials()._asdict()
print(f"export AWS_ACCESS_KEY_ID={creds_dict['access_key']}")
print(f"export AWS_SECRET_ACCESS_KEY={creds_dict['secret_key']}")
print(f"export AWS_SESSION_TOKEN={creds_dict['token']}")
if __name__ == "__main__":
main()