@@ -165,10 +165,10 @@ class StorageType(LowercaseStrEnum):
165165
166166
167167class AwsAuthType (LowercaseStrEnum ):
168+ default = auto ()
168169 credentials = auto ()
169170 profile = auto ()
170171 env_vars = auto ()
171- ec2 = auto ()
172172
173173
174174AwsAuthTypeStr = Annotated [AwsAuthType , StrEnumSerializer ]
@@ -588,7 +588,7 @@ def validate_authentication(cls, data):
588588 raise ValueError (f"profile must be set when type is '{ auth_enum } .'" )
589589 if AwsAuthType .credentials == auth_enum and not credentials :
590590 raise ValueError (f"credentials must be set when type is '{ auth_enum } .'" )
591- if auth_enum in [AwsAuthType .ec2 , AwsAuthType .env_vars ] and (profile or credentials ):
591+ if auth_enum in [AwsAuthType .default , AwsAuthType .env_vars ] and (profile or credentials ):
592592 raise ValueError (f"profile and credentials must not be set when type is '{ auth_enum } .'" )
593593 return data
594594
@@ -951,7 +951,6 @@ def validate_tmp_dir(self, use_host_mount: bool = False):
951951 raise ValueError (f"tmp_directory is invalid: { ex } " )
952952
953953 def validate_aws_config_dir (self , use_host_mount : bool = False ):
954- profile_auth_used = False
955954 auth_configs = []
956955
957956 if StorageType .S3 == self .logs_input .type :
@@ -961,16 +960,23 @@ def validate_aws_config_dir(self, use_host_mount: bool = False):
961960 if StorageType .S3 == self .stream_output .storage .type :
962961 auth_configs .append (self .stream_output .storage .s3_config .aws_authentication )
963962
964- for auth in auth_configs :
965- if AwsAuthType .profile == auth . type :
966- profile_auth_used = True
967- break
963+ auth_types_used = { auth . type for auth in auth_configs }
964+ default_auth_used = AwsAuthType .default in auth_types_used
965+ profile_auth_used = AwsAuthType . profile in auth_types_used
966+ config_dir_allowed = profile_auth_used or default_auth_used
968967
969968 if profile_auth_used :
970969 if self .aws_config_directory is None :
971970 raise ValueError (
972971 "aws_config_directory must be set when using profile authentication"
973972 )
973+
974+ if self .aws_config_directory is not None :
975+ if not config_dir_allowed :
976+ raise ValueError (
977+ "aws_config_directory is only supported with 'profile' or 'default'"
978+ " authentication"
979+ )
974980 resolved_aws_config_dir = (
975981 resolve_host_path_in_container (self .aws_config_directory )
976982 if use_host_mount
@@ -980,10 +986,6 @@ def validate_aws_config_dir(self, use_host_mount: bool = False):
980986 raise ValueError (
981987 f"aws_config_directory does not exist: '{ self .aws_config_directory } '"
982988 )
983- if not profile_auth_used and self .aws_config_directory is not None :
984- raise ValueError (
985- "aws_config_directory should not be set when profile authentication is not used"
986- )
987989
988990 def validate_api_server (self ):
989991 if StorageEngine .CLP == self .package .storage_engine and self .api_server is not None :
0 commit comments