Skip to content

Commit 66c27c3

Browse files
committed
add session creation from supplied access id and secret key
1 parent 94b1b00 commit 66c27c3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

target_s3_parquet/sinks.py

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from typing import Dict, List, Optional
55
import awswrangler as wr
6+
from boto3.session import Session
67
from pandas import DataFrame
78
from singer_sdk import Target
89
from singer_sdk.sinks import BatchSink
@@ -35,7 +36,16 @@ def __init__(
3536
) -> None:
3637
super().__init__(target, stream_name, schema, key_properties)
3738

39+
self._session = Session() if self._is_using_hmac() else Session(
40+
aws_access_key_id=self.config.get("aws_access_key_id"),
41+
aws_secret_access_key=self.config.get("aws_secret_access_key"),
42+
)
43+
3844
self._glue_schema = self._get_glue_schema()
45+
46+
def _is_using_hmac(self) -> bool:
47+
return isinstance(self.config.get("aws_access_key_id"), str) and \
48+
isinstance(self.config.get("aws_secret_access_key"), str)
3949

4050
def _get_glue_schema(self):
4151

@@ -92,6 +102,7 @@ def process_batch(self, context: dict) -> None:
92102
partition_cols=["_sdc_started_at"],
93103
schema_evolution=True,
94104
dtype=dtype,
105+
boto3_session=self._session,
95106
)
96107

97108
self.logger.info(f"Uploaded {len(context['records'])}")

0 commit comments

Comments
 (0)