Skip to content

Commit 9574f9d

Browse files
committed
allow "default" auth to use the custom aws dir as well
1 parent 95116bb commit 9574f9d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

components/clp-py-utils/clp_py_utils/clp_config.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ def validate_tmp_dir(self, use_host_mount: bool = False):
946946
raise ValueError(f"tmp_directory is invalid: {ex}")
947947

948948
def validate_aws_config_dir(self, use_host_mount: bool = False):
949-
profile_auth_used = False
950949
auth_configs = []
951950

952951
if StorageType.S3 == self.logs_input.type:
@@ -956,16 +955,23 @@ def validate_aws_config_dir(self, use_host_mount: bool = False):
956955
if StorageType.S3 == self.stream_output.storage.type:
957956
auth_configs.append(self.stream_output.storage.s3_config.aws_authentication)
958957

959-
for auth in auth_configs:
960-
if AwsAuthType.profile == auth.type:
961-
profile_auth_used = True
962-
break
958+
auth_types_used = {auth.type for auth in auth_configs}
959+
default_auth_used = AwsAuthType.default in auth_types_used
960+
profile_auth_used = AwsAuthType.profile in auth_types_used
961+
config_dir_allowed = profile_auth_used or default_auth_used
963962

964963
if profile_auth_used:
965964
if self.aws_config_directory is None:
966965
raise ValueError(
967966
"aws_config_directory must be set when using profile authentication"
968967
)
968+
969+
if self.aws_config_directory is not None:
970+
if not config_dir_allowed:
971+
raise ValueError(
972+
"aws_config_directory is only supported with 'profile' or 'default'"
973+
" authentication"
974+
)
969975
resolved_aws_config_dir = (
970976
resolve_host_path_in_container(self.aws_config_directory)
971977
if use_host_mount
@@ -975,10 +981,6 @@ def validate_aws_config_dir(self, use_host_mount: bool = False):
975981
raise ValueError(
976982
f"aws_config_directory does not exist: '{self.aws_config_directory}'"
977983
)
978-
if not profile_auth_used and self.aws_config_directory is not None:
979-
raise ValueError(
980-
"aws_config_directory should not be set when profile authentication is not used"
981-
)
982984

983985
def validate_api_server(self):
984986
if StorageEngine.CLP == self.package.storage_engine and self.api_server is not None:

0 commit comments

Comments
 (0)