From 25d45bf3409864e1e7e539935c6da52f84c7d083 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Thu, 19 Sep 2024 13:16:46 -0700 Subject: [PATCH 1/4] test-creds --- .../actions/setup_cross_ci_crt_environment.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/builder/actions/setup_cross_ci_crt_environment.py b/builder/actions/setup_cross_ci_crt_environment.py index 259e70974..30f59770b 100644 --- a/builder/actions/setup_cross_ci_crt_environment.py +++ b/builder/actions/setup_cross_ci_crt_environment.py @@ -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 @@ -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') From bc4823d1541fda42466867f786eb8d1fdcfa1832 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Thu, 19 Sep 2024 13:24:01 -0700 Subject: [PATCH 2/4] fix typo --- builder/actions/setup_cross_ci_crt_environment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/actions/setup_cross_ci_crt_environment.py b/builder/actions/setup_cross_ci_crt_environment.py index 30f59770b..f29a908d4 100644 --- a/builder/actions/setup_cross_ci_crt_environment.py +++ b/builder/actions/setup_cross_ci_crt_environment.py @@ -430,8 +430,8 @@ def _common_setup(self, env): 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) - + result = subprocess.run(['aws', 'sts', 'get-caller-identity'], stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True) # Check if the command was successful if result.returncode == 0: # Parse the JSON output @@ -446,8 +446,8 @@ def get_sts_caller_identity(self): 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()) - + print(f"waahm7: {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') From f4d40905694d7170f8fea5382e4a4fdccf176f53 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Thu, 19 Sep 2024 13:32:47 -0700 Subject: [PATCH 3/4] session token env --- .github/workflows/linux-container-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-container-ci.sh b/.github/workflows/linux-container-ci.sh index 03fd2612a..0e156de3a 100755 --- a/.github/workflows/linux-container-ci.sh +++ b/.github/workflows/linux-container-ci.sh @@ -11,4 +11,4 @@ shift aws ecr get-login-password | docker login 123124136734.dkr.ecr.us-east-1.amazonaws.com -u AWS --password-stdin export DOCKER_IMAGE=123124136734.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:${BUILDER_VERSION} -docker run --env GITHUB_REF --env GITHUB_HEAD_REF --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_DEFAULT_REGION --env CXXFLAGS --env AWS_CRT_ARCH --env CTEST_PARALLEL_LEVEL $DOCKER_IMAGE --version=${BUILDER_VERSION} $@ +docker run --env GITHUB_REF --env GITHUB_HEAD_REF --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --env AWS_DEFAULT_REGION --env CXXFLAGS --env AWS_CRT_ARCH --env CTEST_PARALLEL_LEVEL $DOCKER_IMAGE --version=${BUILDER_VERSION} $@ From 144f537dbc879583c4079f1a765cf03309e45a2c Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Thu, 19 Sep 2024 14:38:28 -0700 Subject: [PATCH 4/4] reset --- .../actions/setup_cross_ci_crt_environment.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/builder/actions/setup_cross_ci_crt_environment.py b/builder/actions/setup_cross_ci_crt_environment.py index f29a908d4..259e70974 100644 --- a/builder/actions/setup_cross_ci_crt_environment.py +++ b/builder/actions/setup_cross_ci_crt_environment.py @@ -1,6 +1,5 @@ # 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 @@ -427,26 +426,9 @@ 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'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE, 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(f"waahm7: {self.get_sts_caller_identity()}") # Bail if not running tests if not env.project.needs_tests(env) and not env_dump_file: