Returns a database user name and temporary password with temporary authorization to log in to Amazon Redshift Serverless.
By default, the temporary credentials expire in 900 seconds. You can optionally specify a duration between 900 seconds (15 minutes) and 3600 seconds (60 minutes).
The Identity and Access Management (IAM) user or role that runs GetCredentials must have an IAM policy attached that allows access to all necessary actions and resources.
If the DbName parameter is specified, the IAM policy must allow access to the resource dbname for the specified database name.
Parameters:
-
db_name
(Optional[DbName], default:
None
)
–
The name of the database to get temporary authorization to log on to.
Constraints:
-
Must be 1 to 64 alphanumeric characters or hyphens.
-
Must contain only uppercase or lowercase letters, numbers, underscore, plus sign, period (dot), at symbol (@), or hyphen.
-
The first character must be a letter.
-
Must not contain a colon ( : ) or slash ( / ).
-
Cannot be a reserved word. A list of reserved words can be found in Reserved Words in the Amazon Redshift Database Developer Guide
-
duration_seconds
(Optional[int], default:
None
)
–
The number of seconds until the returned temporary password expires. The minimum is 900 seconds, and the maximum is 3600 seconds.
-
workgroup_name
(Optional[WorkgroupName], default:
None
)
–
The name of the workgroup associated with the database.
-
custom_domain_name
(Optional[CustomDomainName], default:
None
)
–
The custom domain name associated with the workgroup. The custom domain name or the workgroup name must be included in the request.
Raises:
Source code in docs_src/capo_redshift_serverless/_services/redshift_serverless.py
| def get_credentials(
self,
*,
config_overrides: Optional[RedshiftServerlessClientConfig] = None,
db_name: Optional["capo_redshift_serverless.types.db_name.DbName"] = None,
duration_seconds: Optional[int] = None,
workgroup_name: Optional[
"capo_redshift_serverless.types.workgroup_name.WorkgroupName"
] = None,
custom_domain_name: Optional[
"capo_redshift_serverless.types.custom_domain_name.CustomDomainName"
] = None,
) -> (
"capo_redshift_serverless.types.get_credentials_response.GetCredentialsResponse"
):
"""<p>Returns a database user name and temporary password with temporary authorization to log in to Amazon Redshift Serverless.</p> <p>By default, the temporary credentials expire in 900 seconds. You can optionally specify a duration between 900 seconds (15 minutes) and 3600 seconds (60 minutes).</p> <p>The Identity and Access Management (IAM) user or role that runs GetCredentials must have an IAM policy attached that allows access to all necessary actions and resources.</p> <p>If the <code>DbName</code> parameter is specified, the IAM policy must allow access to the resource dbname for the specified database name.</p>
Args:
db_name: <p>The name of the database to get temporary authorization to log on to.</p> <p>Constraints:</p> <ul> <li> <p>Must be 1 to 64 alphanumeric characters or hyphens.</p> </li> <li> <p>Must contain only uppercase or lowercase letters, numbers, underscore, plus sign, period (dot), at symbol (@), or hyphen.</p> </li> <li> <p>The first character must be a letter.</p> </li> <li> <p>Must not contain a colon ( : ) or slash ( / ).</p> </li> <li> <p>Cannot be a reserved word. A list of reserved words can be found in <a href="https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html">Reserved Words </a> in the Amazon Redshift Database Developer Guide</p> </li> </ul>
duration_seconds: <p>The number of seconds until the returned temporary password expires. The minimum is 900 seconds, and the maximum is 3600 seconds.</p>
workgroup_name: <p>The name of the workgroup associated with the database.</p>
custom_domain_name: <p>The custom domain name associated with the workgroup. The custom domain name or the workgroup name must be included in the request.</p>
Raises:
capo_redshift_serverless.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
capo_redshift_serverless.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource could not be found.</p>
capo_redshift_serverless.errors.validation_exception.ValidationException: <p>The input failed to satisfy the constraints specified by an Amazon Web Services service.</p>
capo_redshift_serverless.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_redshift_serverless.types.get_credentials_request.GetCredentialsRequest]",
) -> OperationResponse[
"capo_redshift_serverless.types.get_credentials_response.GetCredentialsResponse"
]:
import capo_redshift_serverless._operations.redshift_serverless.get_credentials
output, http_response = (
capo_redshift_serverless._operations.redshift_serverless.get_credentials.get_credentials(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_output(
output: "capo_redshift_serverless.types.get_credentials_response.GetCredentialsResponse",
) -> dict[str, Any]:
import capo_redshift_serverless.types.get_credentials_response
return capo_redshift_serverless.types.get_credentials_response.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("GetCredentials", redact_output=_redact_output),
)
input_: capo_redshift_serverless.types.get_credentials_request.GetCredentialsRequest = {}
if db_name is not None:
input_["db_name"] = db_name
if duration_seconds is not None:
input_["duration_seconds"] = duration_seconds
if workgroup_name is not None:
input_["workgroup_name"] = workgroup_name
if custom_domain_name is not None:
input_["custom_domain_name"] = custom_domain_name
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|