generate_db_connect_auth_token(
*,
hostname: str,
expires_in: int = 900,
config_overrides: AsyncDSQLClientConfig | None = None,
) -> str
An IAM authentication token to connect to an Aurora DSQL cluster as a custom database role: pass it as the password. It is signed locally with the client's credentials and region, so nothing is sent to AWS.
Parameters:
-
hostname
(str)
–
The cluster's endpoint, such as abc123.dsql.us-east-1.on.aws.
-
expires_in
(int, default:
900
)
–
How long the token stays valid, in seconds; at most 604800, a week.
-
config_overrides
(AsyncDSQLClientConfig | None, default:
None
)
–
Client settings for this call only, such as another region or credentials_provider.
Source code in docs_src/capo_dsql/_services/async_dsql.py
| async def generate_db_connect_auth_token(
self,
*,
hostname: str,
expires_in: int = 900,
config_overrides: AsyncDSQLClientConfig | None = None,
) -> str:
"""An IAM authentication token to connect to an Aurora DSQL cluster as a custom database role: pass it as the password. It is signed locally with the client's credentials and region, so nothing is sent to AWS.
Args:
hostname: The cluster's endpoint, such as ``abc123.dsql.us-east-1.on.aws``.
expires_in: How long the token stays valid, in seconds; at most 604800, a week.
config_overrides: Client settings for this call only, such as another ``region`` or ``credentials_provider``.
"""
_, options_ = self.operation_options(config_overrides)
# Where an API call would take the region from: the client, else AWS_REGION or the profile
region = options_.region or load_aws_settings().region
if region is None:
raise ValueError("an auth token needs a region: pass region= to the client")
provider = options_.credentials_provider
if provider is None:
raise RuntimeError("an auth token needs credentials")
credentials = await provider.aresolve_identity()
return presign_auth_token(
hostname,
{"Action": "DbConnect"},
credentials=credentials,
region=region,
signing_name="dsql",
expires_in=expires_in,
)
|