get_random_password
¶
get_random_password(
*,
config_overrides: Optional[SecretsManagerClientConfig] = None,
password_length: Optional[PasswordLengthType] = None,
exclude_characters: Optional[ExcludeCharactersType] = None,
exclude_numbers: Optional[ExcludeNumbersType] = None,
exclude_punctuation: Optional[ExcludePunctuationType] = None,
exclude_uppercase: Optional[ExcludeUppercaseType] = None,
exclude_lowercase: Optional[ExcludeLowercaseType] = None,
include_space: Optional[IncludeSpaceType] = None,
require_each_included_type: Optional[RequireEachIncludedTypeType] = None,
) -> GetRandomPasswordResponse
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. By default, Secrets Manager uses uppercase and lowercase letters, numbers, and the following characters in passwords: !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~
Secrets Manager generates a CloudTrail log entry when you call this action.
Required permissions: secretsmanager:GetRandomPassword. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager.
Parameters:
-
password_length(Optional[PasswordLengthType], default:None) –The length of the password. If you don't include this parameter, the default length is 32 characters.
-
exclude_characters(Optional[ExcludeCharactersType], default:None) –A string of the characters that you don't want in the password.
-
exclude_numbers(Optional[ExcludeNumbersType], default:None) –Specifies whether to exclude numbers from the password. If you don't include this switch, the password can contain numbers.
-
exclude_punctuation(Optional[ExcludePunctuationType], default:None) –Specifies whether to exclude the following punctuation characters from the password:
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~. If you don't include this switch, the password can contain punctuation. -
exclude_uppercase(Optional[ExcludeUppercaseType], default:None) –Specifies whether to exclude uppercase letters from the password. If you don't include this switch, the password can contain uppercase letters.
-
exclude_lowercase(Optional[ExcludeLowercaseType], default:None) –Specifies whether to exclude lowercase letters from the password. If you don't include this switch, the password can contain lowercase letters.
-
include_space(Optional[IncludeSpaceType], default:None) –Specifies whether to include the space character. If you include this switch, the password can contain space characters.
-
require_each_included_type(Optional[RequireEachIncludedTypeType], default:None) –Specifies whether to include at least one upper and lowercase letter, one number, and one punctuation. If you don't include this switch, the password contains at least one of every character type.
Raises:
-
InternalServiceError–An error occurred on the server side.
-
InvalidParameterException–The parameter name or value is invalid.
-
InvalidRequestException–A parameter value is not valid for the current state of the resource.
Possible causes:
-
The secret is scheduled for deletion.
-
You tried to enable rotation on a secret that doesn't already have a Lambda function ARN configured and you didn't include such an ARN as a parameter in this call.
-
The secret is managed by another service, and you must use that service to update it. For more information, see Secrets managed by other Amazon Web Services services.
-
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To generate a random password 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.
>>> client.get_random_password(password_length=20, include_space=True, require_each_included_type=True)
Source code in docs_src/capo_secrets_manager/_services/secrets_manager.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | |