Skip to content

Commit 781b773

Browse files
Minor - Adding Secrets Manager Endpoint (#946)
Co-authored-by: kukushking <[email protected]>
1 parent 8b20f2c commit 781b773

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

awswrangler/_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class _ConfigArg(NamedTuple):
4444
"kms_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
4545
"emr_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
4646
"dynamodb_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
47+
"secretsmanager_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
4748
# Botocore config
4849
"botocore_config": _ConfigArg(dtype=botocore.config.Config, nullable=True),
4950
}
@@ -63,6 +64,7 @@ def __init__(self) -> None:
6364
self.kms_endpoint_url = None
6465
self.emr_endpoint_url = None
6566
self.dynamodb_endpoint_url = None
67+
self.secretsmanager_endpoint_url = None
6668
self.botocore_config = None
6769
for name in _CONFIG_ARGS:
6870
self._load_config(name=name)
@@ -363,6 +365,15 @@ def dynamodb_endpoint_url(self) -> Optional[str]:
363365
def dynamodb_endpoint_url(self, value: Optional[str]) -> None:
364366
self._set_config_value(key="dynamodb_endpoint_url", value=value)
365367

368+
@property
369+
def secretsmanager_endpoint_url(self) -> Optional[str]:
370+
"""Property secretsmanager_endpoint_url."""
371+
return cast(Optional[str], self["secretsmanager_endpoint_url"])
372+
373+
@secretsmanager_endpoint_url.setter
374+
def secretsmanager_endpoint_url(self, value: Optional[str]) -> None:
375+
self._set_config_value(key="secretsmanager_endpoint_url", value=value)
376+
366377
@property
367378
def botocore_config(self) -> botocore.config.Config:
368379
"""Property botocore_config."""

awswrangler/_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def _get_endpoint_url(service_name: str) -> Optional[str]:
9595
endpoint_url = _config.config.emr_endpoint_url
9696
elif service_name == "dynamodb" and _config.config.dynamodb_endpoint_url is not None:
9797
endpoint_url = _config.config.dynamodb_endpoint_url
98+
elif service_name == "secretsmanager" and _config.config.secretsmanager_endpoint_url is not None:
99+
endpoint_url = _config.config.secretsmanager_endpoint_url
98100
return endpoint_url
99101

100102

tests/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def wrapper(self, **kwarg):
2929
assert url == wr.config.s3_endpoint_url
3030
elif name == "glue":
3131
assert url == wr.config.glue_endpoint_url
32+
elif name == "secretsmanager":
33+
assert url == wr.config.secretsmanager_endpoint_url
3234
return original(self, **kwarg)
3335

3436
with patch("botocore.client.ClientCreator.create_client", new=wrapper):
@@ -112,11 +114,13 @@ def test_basics(path, glue_database, glue_table, workgroup0, workgroup1):
112114
wr.config.s3_endpoint_url = f"https://s3.{region}.amazonaws.com"
113115
wr.config.athena_endpoint_url = f"https://athena.{region}.amazonaws.com"
114116
wr.config.glue_endpoint_url = f"https://glue.{region}.amazonaws.com"
117+
wr.config.secretsmanager_endpoint_url = f"https://secretsmanager.{region}.amazonaws.com"
115118
_urls_test(glue_database)
116119
os.environ["WR_STS_ENDPOINT_URL"] = f"https://sts.{region}.amazonaws.com"
117120
os.environ["WR_S3_ENDPOINT_URL"] = f"https://s3.{region}.amazonaws.com"
118121
os.environ["WR_ATHENA_ENDPOINT_URL"] = f"https://athena.{region}.amazonaws.com"
119122
os.environ["WR_GLUE_ENDPOINT_URL"] = f"https://glue.{region}.amazonaws.com"
123+
os.environ["WR_SECRETSMANAGER_ENDPOINT_URL"] = f"https://secretsmanager.{region}.amazonaws.com"
120124
wr.config.reset()
121125
_urls_test(glue_database)
122126

0 commit comments

Comments
 (0)