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
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 | |