@@ -245,14 +245,12 @@ def __init__(self, **data: Any): # noqa: C901
245245 logger .info ("running inside GitHub Actions" )
246246 aws_access_key_id = os .environ .get ("AWS_ACCESS_KEY_ID" , None )
247247 aws_secret_access_key = os .environ .get ("AWS_SECRET_ACCESS_KEY" , None )
248- if not aws_access_key_id or not aws_secret_access_key :
248+ if not aws_access_key_id or not aws_secret_access_key and not self . aws_profile :
249249 raise RekognitionConfigurationError (
250250 "required environment variable(s) AWS_ACCESS_KEY_ID and/or AWS_SECRET_ACCESS_KEY not set"
251251 )
252- self ._aws_access_key_id_source = "environ"
253- self ._aws_secret_access_key_source = "environ"
254252 region_name = os .environ .get ("AWS_REGION" , None )
255- if not region_name :
253+ if not region_name and not self . aws_profile :
256254 raise RekognitionConfigurationError ("required environment variable AWS_REGION not set" )
257255 try :
258256 self ._aws_session = boto3 .Session (
@@ -266,9 +264,13 @@ def __init__(self, **data: Any): # noqa: C901
266264 except ProfileNotFound :
267265 logger .warning ("aws_profile %s not found" , self .aws_profile )
268266
269- if self .aws_profile and self . _aws_access_key_id_source == "unset" :
267+ if self .aws_profile :
270268 self ._aws_access_key_id_source = "aws_profile"
271269 self ._aws_secret_access_key_source = "aws_profile"
270+ else :
271+ self ._aws_access_key_id_source = "environ"
272+ self ._aws_secret_access_key_source = "environ"
273+
272274 self ._initialized = True
273275
274276 if not self .initialized :
0 commit comments