Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/add s3 region for redshift staging destination related to 2349 #2389

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion dlt/destinations/impl/redshift/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ def __init__(
file_path: str,
staging_credentials: Optional[CredentialsConfiguration] = None,
staging_iam_role: str = None,
staging_region_name: str = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would have to be made part of the RedshiftClientConfiguration and then passed to the load-job

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd thought here: if we add to the configuration, we will have to add a lot of tests, i assume so maybe let me have a chat with my colleagues here
@sh-rp

) -> None:
super().__init__(file_path, staging_credentials)
self._staging_iam_role = staging_iam_role
self._region_name = staging_region_name
self._job_client: "RedshiftClient" = None

def run(self) -> None:
Expand All @@ -76,15 +78,22 @@ def run(self) -> None:
credentials = ""
if self._staging_iam_role:
credentials = f"IAM_ROLE '{self._staging_iam_role}'"
if self._region_name:
credentials += f" REGION '{self._region_name}'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yannik207 it should be possible to use self._staging_credentials.region_namen here and not have to introduce a new setting, no? You should have this already set to the correct region since you need it to upload the files to the staging destination in the first place. So from my point of view we only need to add these two lines but insert from a different place. Let me know if I am missing something here.

elif self._staging_credentials and isinstance(
self._staging_credentials, AwsCredentialsWithoutDefaults
):
aws_access_key = self._staging_credentials.aws_access_key_id
aws_secret_key = self._staging_credentials.aws_secret_access_key
region_name = self._staging_credentials.region_name
credentials = (
"CREDENTIALS"
f" 'aws_access_key_id={aws_access_key};aws_secret_access_key={aws_secret_key}'"
f" 'aws_access_key_id={aws_access_key};aws_secret_access_key={aws_secret_key}"
)
if region_name:
credentials += f"region={region_name};"

credentials += "'" # Closing single quote

# get format
ext = os.path.splitext(self._bucket_path)[1][1:]
Expand Down