From d19dbc67b7d6032f8ba39adb1aedfc2d48bca0c2 Mon Sep 17 00:00:00 2001 From: Leonardo Horta Date: Wed, 17 Apr 2024 10:37:03 -0300 Subject: [PATCH] Added profile_name to boto3 Session Needed when working with multiple S3 profiles on the same machine --- dbt/adapters/duckdb/credentials.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dbt/adapters/duckdb/credentials.py b/dbt/adapters/duckdb/credentials.py index 9edcffc9..e3594d13 100644 --- a/dbt/adapters/duckdb/credentials.py +++ b/dbt/adapters/duckdb/credentials.py @@ -234,7 +234,11 @@ def load_settings(self) -> Dict[str, str]: settings = self.settings or {} if self.use_credential_provider: if self.use_credential_provider == "aws": - settings.update(_load_aws_credentials(ttl=_get_ttl_hash())) + settings.update( + _load_aws_credentials( + ttl=_get_ttl_hash(), profile=settings.get("s3_profile") + ), + ) else: raise ValueError( "Unsupported value for use_credential_provider: " @@ -248,7 +252,7 @@ def _get_ttl_hash(seconds=300): @lru_cache() -def _load_aws_credentials(ttl=None) -> Dict[str, Any]: +def _load_aws_credentials(ttl=None, profile="default") -> Dict[str, Any]: """ Load AWS credentials from the environment. @@ -260,7 +264,7 @@ def _load_aws_credentials(ttl=None) -> Dict[str, Any]: del ttl # make mypy happy import boto3.session - session = boto3.session.Session() + session = boto3.session.Session(profile_name=profile) # use STS to verify that the credentials are valid; we will # raise a helpful error here if they are not