Changes the password of the IAM user who is calling this operation. This operation can be performed using the CLI, the Amazon Web Services API, or the My Security Credentials page in the Amazon Web Services Management Console. The Amazon Web Services account root user password is not affected by this operation.
Use UpdateLoginProfile to use the CLI, the Amazon Web Services API, or the Users page in the IAM console to change the password for any IAM user. For more information about modifying passwords, see Managing passwords in the IAM User Guide.
Parameters:
-
old_password
(passwordType)
–
The IAM user's current password.
-
new_password
(passwordType)
–
The new password. The new password must conform to the Amazon Web Services account's password policy, if one exists.
The regex pattern that is used to validate this parameter is a string of characters. That string can include almost any printable ASCII character from the space (\u0020) through the end of the ASCII character range (\u00FF). You can also include the tab (\u0009), line feed (\u000A), and carriage return (\u000D) characters. Any of these characters are valid in a password. However, many tools, such as the Amazon Web Services Management Console, might restrict the ability to type certain characters because they have special meaning within that tool.
Raises:
-
EntityTemporarilyUnmodifiableException
–
The request was rejected because it referenced an entity that is temporarily unmodifiable, such as a user name that was deleted and then recreated. The error indicates that the request is likely to succeed if you try again after waiting several minutes. The error message describes the entity.
-
InvalidUserTypeException
–
The request was rejected because the type of user for the transaction was incorrect.
-
LimitExceededException
–
The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.
-
NoSuchEntityException
–
The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.
-
PasswordPolicyViolationException
–
The request was rejected because the provided password did not meet the requirements imposed by the account password policy.
-
ServiceFailureException
–
The request processing has failed because of an unknown error, exception or failure.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To change the password for your IAM user
The following command changes the password for the current IAM user.
>>> client.change_password(new_password=']35d/{pB9Fo9wJ', old_password='3s0K_;xh4~8XXI')
Source code in docs_src/capo_iam/_services/iam.py
| def change_password(
self,
old_password: "capo_iam.types.password_type.passwordType",
new_password: "capo_iam.types.password_type.passwordType",
*,
config_overrides: Optional[IAMClientConfig] = None,
) -> None:
r"""<p>Changes the password of the IAM user who is calling this operation. This operation can be performed using the CLI, the Amazon Web Services API, or the <b>My Security Credentials</b> page in the Amazon Web Services Management Console. The Amazon Web Services account root user password is not affected by this operation.</p> <p>Use <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateLoginProfile.html">UpdateLoginProfile</a> to use the CLI, the Amazon Web Services API, or the <b>Users</b> page in the IAM console to change the password for any IAM user. For more information about modifying passwords, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_ManagingLogins.html">Managing passwords</a> in the <i>IAM User Guide</i>.</p>
Args:
old_password: <p>The IAM user's current password.</p>
new_password: <p>The new password. The new password must conform to the Amazon Web Services account's password policy, if one exists.</p> <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> that is used to validate this parameter is a string of characters. That string can include almost any printable ASCII character from the space (<code>\u0020</code>) through the end of the ASCII character range (<code>\u00FF</code>). You can also include the tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>) characters. Any of these characters are valid in a password. However, many tools, such as the Amazon Web Services Management Console, might restrict the ability to type certain characters because they have special meaning within that tool.</p>
Raises:
capo_iam.errors.entity_temporarily_unmodifiable_exception.EntityTemporarilyUnmodifiableException: <p>The request was rejected because it referenced an entity that is temporarily unmodifiable, such as a user name that was deleted and then recreated. The error indicates that the request is likely to succeed if you try again after waiting several minutes. The error message describes the entity.</p>
capo_iam.errors.invalid_user_type_exception.InvalidUserTypeException: <p>The request was rejected because the type of user for the transaction was incorrect.</p>
capo_iam.errors.limit_exceeded_exception.LimitExceededException: <p>The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.</p>
capo_iam.errors.no_such_entity_exception.NoSuchEntityException: <p>The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.</p>
capo_iam.errors.password_policy_violation_exception.PasswordPolicyViolationException: <p>The request was rejected because the provided password did not meet the requirements imposed by the account password policy.</p>
capo_iam.errors.service_failure_exception.ServiceFailureException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
capo_iam.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To change the password for your IAM user
The following command changes the password for the current IAM user.
>>> client.change_password(new_password=']35d/{pB9Fo9wJ', old_password='3s0K_;xh4~8XXI')
"""
def _handler(
req: "OperationRequest[capo_iam.types.change_password_request.ChangePasswordRequest]",
) -> OperationResponse[None]:
import capo_iam._operations.aws_identity_management_v20100508.change_password
output, http_response = (
capo_iam._operations.aws_identity_management_v20100508.change_password.change_password(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_iam.types.change_password_request.ChangePasswordRequest",
) -> dict[str, Any]:
import capo_iam.types.change_password_request
return capo_iam.types.change_password_request.redact_sensitive(input_)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("ChangePassword", redact_input=_redact_input),
)
input_: capo_iam.types.change_password_request.ChangePasswordRequest = {
"old_password": old_password,
"new_password": new_password,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|