From 1e2865568b7a4d035709b792d76caeefbd40bd97 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Sat, 30 Dec 2023 06:43:36 -0600 Subject: [PATCH] test: revert aws key source logic --- terraform/python/rekognition_api/conf.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/terraform/python/rekognition_api/conf.py b/terraform/python/rekognition_api/conf.py index cad6ef5..4e9ae42 100644 --- a/terraform/python/rekognition_api/conf.py +++ b/terraform/python/rekognition_api/conf.py @@ -245,14 +245,12 @@ def __init__(self, **data: Any): # noqa: C901 logger.info("running inside GitHub Actions") aws_access_key_id = os.environ.get("AWS_ACCESS_KEY_ID", None) aws_secret_access_key = os.environ.get("AWS_SECRET_ACCESS_KEY", None) - if not aws_access_key_id or not aws_secret_access_key: + if not aws_access_key_id or not aws_secret_access_key and not self.aws_profile: raise RekognitionConfigurationError( "required environment variable(s) AWS_ACCESS_KEY_ID and/or AWS_SECRET_ACCESS_KEY not set" ) - self._aws_access_key_id_source = "environ" - self._aws_secret_access_key_source = "environ" region_name = os.environ.get("AWS_REGION", None) - if not region_name: + if not region_name and not self.aws_profile: raise RekognitionConfigurationError("required environment variable AWS_REGION not set") try: self._aws_session = boto3.Session( @@ -266,9 +264,13 @@ def __init__(self, **data: Any): # noqa: C901 except ProfileNotFound: logger.warning("aws_profile %s not found", self.aws_profile) - if self.aws_profile and self._aws_access_key_id_source == "unset": + if self.aws_profile: self._aws_access_key_id_source = "aws_profile" self._aws_secret_access_key_source = "aws_profile" + else: + self._aws_access_key_id_source = "environ" + self._aws_secret_access_key_source = "environ" + self._initialized = True if not self.initialized: