get_random_password
(**kwargs)¶Generates a random password. We recommend that you specify the maximum length and include every character type that the system you are generating a password for can support.
Secrets Manager generates a CloudTrail log entry when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see Logging Secrets Manager events with CloudTrail.
Required permissions:secretsmanager:GetRandomPassword
. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager.
See also: AWS API Documentation
Request Syntax
response = client.get_random_password(
PasswordLength=123,
ExcludeCharacters='string',
ExcludeNumbers=True|False,
ExcludePunctuation=True|False,
ExcludeUppercase=True|False,
ExcludeLowercase=True|False,
IncludeSpace=True|False,
RequireEachIncludedType=True|False
)
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
. If you don't include this switch, the password can contain punctuation.dict
Response Syntax
{
'RandomPassword': 'string'
}
Response Structure
(dict) --
RandomPassword (string) --
A string with the password.
Exceptions
SecretsManager.Client.exceptions.InvalidParameterException
SecretsManager.Client.exceptions.InvalidRequestException
SecretsManager.Client.exceptions.InternalServiceError
Examples
The following example shows how to request a randomly generated password. This example includes the optional flags to require spaces and at least one character of each included type. It specifies a length of 20 characters.
response = client.get_random_password(
IncludeSpace=True,
PasswordLength=20,
RequireEachIncludedType=True,
)
print(response)
Expected Output:
{
'RandomPassword': 'EXAMPLE-PASSWORD',
'ResponseMetadata': {
'...': '...',
},
}