|
1 | 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2 | 2 | # SPDX-License-Identifier: Apache-2.0.
|
| 3 | +import subprocess |
3 | 4 |
|
4 | 5 | from builder.core.action import Action
|
5 | 6 | from builder.core.host import current_os, current_arch
|
@@ -426,10 +427,27 @@ def _common_setup(self, env):
|
426 | 427 |
|
427 | 428 | pass
|
428 | 429 |
|
| 430 | + def get_sts_caller_identity(self): |
| 431 | + try: |
| 432 | + # Run AWS CLI command to get STS caller identity |
| 433 | + result = subprocess.run(['aws', 'sts', 'get-caller-identity'], capture_output=True, text=True) |
| 434 | + |
| 435 | + # Check if the command was successful |
| 436 | + if result.returncode == 0: |
| 437 | + # Parse the JSON output |
| 438 | + caller_identity = json.loads(result.stdout) |
| 439 | + print("Caller Identity:", json.dumps(caller_identity, indent=4)) |
| 440 | + else: |
| 441 | + print(f"Error: {result.stderr}") |
| 442 | + |
| 443 | + except Exception as e: |
| 444 | + print(f"An error occurred: {e}") |
| 445 | + |
429 | 446 | def run(self, env):
|
430 | 447 | # A special environment variable indicating that we want to dump test environment variables to a specified file.
|
431 | 448 | env_dump_file = env.shell.getenv("AWS_SETUP_CRT_TEST_ENVIRONMENT_DUMP_FILE")
|
432 |
| - |
| 449 | + print(self.get_sts_caller_identity()) |
| 450 | + |
433 | 451 | # Bail if not running tests
|
434 | 452 | if not env.project.needs_tests(env) and not env_dump_file:
|
435 | 453 | print('Tests not needed for project. Skipping setting test environment variables')
|
|
0 commit comments