Skip to content

Commit

Permalink
test: revert aws key source logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Dec 30, 2023
1 parent 59a3a36 commit 1e28655
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions terraform/python/rekognition_api/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit 1e28655

Please sign in to comment.