Skip to content

Commit 25d45bf

Browse files
committed
test-creds
1 parent 152d863 commit 25d45bf

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

builder/actions/setup_cross_ci_crt_environment.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0.
3+
import subprocess
34

45
from builder.core.action import Action
56
from builder.core.host import current_os, current_arch
@@ -426,10 +427,27 @@ def _common_setup(self, env):
426427

427428
pass
428429

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+
429446
def run(self, env):
430447
# A special environment variable indicating that we want to dump test environment variables to a specified file.
431448
env_dump_file = env.shell.getenv("AWS_SETUP_CRT_TEST_ENVIRONMENT_DUMP_FILE")
432-
449+
print(self.get_sts_caller_identity())
450+
433451
# Bail if not running tests
434452
if not env.project.needs_tests(env) and not env_dump_file:
435453
print('Tests not needed for project. Skipping setting test environment variables')

0 commit comments

Comments
 (0)