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

feat(ingest): support advanced configs for aws #9237

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all 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
29 changes: 23 additions & 6 deletions metadata-ingestion/src/datahub/ingestion/source/aws/aws_common.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import TYPE_CHECKING, Dict, List, Optional, Union
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

import boto3
from boto3.session import Session
from botocore.config import Config
from botocore.config import DEFAULT_TIMEOUT, Config
from botocore.utils import fix_s3_host
from pydantic.fields import Field

Expand Down Expand Up @@ -104,6 +104,16 @@ class AwsConnectionConfig(ConfigModel):
description="A set of proxy configs to use with AWS. See the [botocore.config](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html) docs for details.",
)

read_timeout: float = Field(
default=DEFAULT_TIMEOUT,
description="The timeout for reading from the connection (in seconds).",
)

aws_advanced_config: Dict[str, Any] = Field(
default_factory=dict,
description="Advanced AWS configuration options. These are passed directly to [botocore.config.Config](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html).",
)

def _normalized_aws_roles(self) -> List[AwsAssumeRoleConfig]:
if not self.aws_role:
return []
Expand Down Expand Up @@ -167,13 +177,20 @@ def get_credentials(self) -> Dict[str, str]:
}
return {}

def _aws_config(self) -> Config:
return Config(
proxies=self.aws_proxy,
read_timeout=self.read_timeout,
**self.aws_advanced_config,
)

def get_s3_client(
self, verify_ssl: Optional[Union[bool, str]] = None
) -> "S3Client":
return self.get_session().client(
"s3",
endpoint_url=self.aws_endpoint_url,
config=Config(proxies=self.aws_proxy),
config=self._aws_config(),
verify=verify_ssl,
)

Expand All @@ -183,7 +200,7 @@ def get_s3_resource(
resource = self.get_session().resource(
"s3",
endpoint_url=self.aws_endpoint_url,
config=Config(proxies=self.aws_proxy),
config=self._aws_config(),
verify=verify_ssl,
)
# according to: https://stackoverflow.com/questions/32618216/override-s3-endpoint-using-boto3-configuration-file
Expand All @@ -195,10 +212,10 @@ def get_s3_resource(
return resource

def get_glue_client(self) -> "GlueClient":
return self.get_session().client("glue")
return self.get_session().client("glue", config=self._aws_config())

def get_sagemaker_client(self) -> "SageMakerClient":
return self.get_session().client("sagemaker")
return self.get_session().client("sagemaker", config=self._aws_config())


class AwsSourceConfig(EnvConfigMixin, AwsConnectionConfig):
Expand Down
Loading