Skip to content

Commit

Permalink
test-creds
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 committed Sep 19, 2024
1 parent 152d863 commit 25d45bf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion builder/actions/setup_cross_ci_crt_environment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
import subprocess

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

pass

def get_sts_caller_identity(self):
try:
# Run AWS CLI command to get STS caller identity
result = subprocess.run(['aws', 'sts', 'get-caller-identity'], capture_output=True, text=True)

# Check if the command was successful
if result.returncode == 0:
# Parse the JSON output
caller_identity = json.loads(result.stdout)
print("Caller Identity:", json.dumps(caller_identity, indent=4))
else:
print(f"Error: {result.stderr}")

except Exception as e:
print(f"An error occurred: {e}")

def run(self, env):
# A special environment variable indicating that we want to dump test environment variables to a specified file.
env_dump_file = env.shell.getenv("AWS_SETUP_CRT_TEST_ENVIRONMENT_DUMP_FILE")

print(self.get_sts_caller_identity())

# Bail if not running tests
if not env.project.needs_tests(env) and not env_dump_file:
print('Tests not needed for project. Skipping setting test environment variables')
Expand Down

0 comments on commit 25d45bf

Please sign in to comment.