Skip to content

update_login_profile

update_login_profile(
    user_name: userNameType,
    *,
    config_overrides: Optional[IAMClientConfig] = None,
    password: Optional[passwordType] = None,
    password_reset_required: Optional[booleanObjectType] = None,
    max_signin_session_duration: Optional[maxSigninSessionDurationType] = None,
    reset_max_signin_session_duration: Optional[booleanObjectType] = None,
) -> None

Changes the password or the maximum sign-in session duration for the specified IAM user. You can use the CLI, the Amazon Web Services API, or the Users page in the IAM console to change the password for any IAM user. Use ChangePassword to change your own password in the My Security Credentials page in the Amazon Web Services Management Console.

For more information about modifying passwords, see Managing passwords in the IAM User Guide.

Parameters:

  • user_name (userNameType) –

    The name of the user whose password you want to update.

    This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

  • password (Optional[passwordType], default: None ) –

    The new password for the specified IAM user.

    The regex pattern used to validate this parameter is a string of characters consisting of the following:

    • Any printable ASCII character ranging from the space character (\u0020) through the end of the ASCII character range

    • The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)

    • The special characters tab (\u0009), line feed (\u000A), and carriage return (\u000D)

    However, the format can be further restricted by the account administrator by setting a password policy on the Amazon Web Services account. For more information, see UpdateAccountPasswordPolicy.

  • password_reset_required (Optional[booleanObjectType], default: None ) –

    Allows this new password to be used only once by requiring the specified IAM user to set a new password on next sign-in.

  • max_signin_session_duration (Optional[maxSigninSessionDurationType], default: None ) –

    The maximum duration (in seconds) of an Amazon Web Services Sign-In session that uses the specified IAM user's login profile (user name and password). This setting can have a value from 1 hour (3600 seconds) to 90 days (7776000 seconds), inclusive.

    This setting applies only to sessions created through OAuth-based flows (signin:CreateOAuth2Token). It does not affect Amazon Web Services Management Console browser sessions or traditional STS sessions.

    If you omit both this parameter and ResetMaxSigninSessionDuration, the current setting is unchanged. You cannot specify this parameter and set ResetMaxSigninSessionDuration to true in the same request. If you update only the sign-in session duration, the user's password and PasswordResetRequired setting do not change.

    Changes to this setting apply to new sign-in sessions. Sessions that are already established are not affected.

    This setting is not supported for the root user.

  • reset_max_signin_session_duration (Optional[booleanObjectType], default: None ) –

    Specifies whether to clear the maximum sign-in session duration on the specified IAM user's login profile. Set this value to true to return the setting to its unset state, so that the existing sign-in session behavior applies.

    If you set this value to false or omit it, the current setting is not cleared. You cannot set this value to true and specify MaxSigninSessionDuration in the same request. Clearing a setting that is already unset has no effect.

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.

  • InvalidInputException –

    The request was rejected because an invalid or out-of-range value was supplied for an input parameter.

  • 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 an IAM user The following command creates or changes the password for the IAM user named Bob.

>>> client.update_login_profile(user_name='Bob', password='SomeKindOfPassword123!@#')
Source code in docs_src/capo_iam/_services/iam.py
def update_login_profile(
    self,
    user_name: "capo_iam.types.user_name_type.userNameType",
    *,
    config_overrides: Optional[IAMClientConfig] = None,
    password: Optional["capo_iam.types.password_type.passwordType"] = None,
    password_reset_required: Optional[
        "capo_iam.types.boolean_object_type.booleanObjectType"
    ] = None,
    max_signin_session_duration: Optional[
        "capo_iam.types.max_signin_session_duration_type.maxSigninSessionDurationType"
    ] = None,
    reset_max_signin_session_duration: Optional[
        "capo_iam.types.boolean_object_type.booleanObjectType"
    ] = None,
) -> None:
    r"""<p>Changes the password or the maximum sign-in session duration for the specified IAM user. You can 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. Use <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_ChangePassword.html">ChangePassword</a> to change your own password in the <b>My Security Credentials</b> page in the Amazon Web Services Management Console.</p> <p>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:
        user_name: <p>The name of the user whose password you want to update.</p> <p>This parameter allows (through its <a href="http://wikipedia.org/wiki/regex">regex pattern</a>) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-</p>
        password: <p>The new password for the specified IAM user.</p> <p>The <a href="http://wikipedia.org/wiki/regex">regex pattern</a> used to validate this parameter is a string of characters consisting of the following:</p> <ul> <li> <p>Any printable ASCII character ranging from the space character (<code>\u0020</code>) through the end of the ASCII character range</p> </li> <li> <p>The printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>)</p> </li> <li> <p>The special characters tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>)</p> </li> </ul> <p>However, the format can be further restricted by the account administrator by setting a password policy on the Amazon Web Services account. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_UpdateAccountPasswordPolicy.html">UpdateAccountPasswordPolicy</a>.</p>
        password_reset_required: <p>Allows this new password to be used only once by requiring the specified IAM user to set a new password on next sign-in.</p>
        max_signin_session_duration: <p>The maximum duration (in seconds) of an Amazon Web Services Sign-In session that uses the specified IAM user's login profile (user name and password). This setting can have a value from 1 hour (3600 seconds) to 90 days (7776000 seconds), inclusive.</p> <p>This setting applies only to sessions created through OAuth-based flows (<code>signin:CreateOAuth2Token</code>). It does not affect Amazon Web Services Management Console browser sessions or traditional STS sessions.</p> <p>If you omit both this parameter and <code>ResetMaxSigninSessionDuration</code>, the current setting is unchanged. You cannot specify this parameter and set <code>ResetMaxSigninSessionDuration</code> to <code>true</code> in the same request. If you update only the sign-in session duration, the user's password and <code>PasswordResetRequired</code> setting do not change.</p> <p>Changes to this setting apply to new sign-in sessions. Sessions that are already established are not affected.</p> <note> <p>This setting is not supported for the root user.</p> </note>
        reset_max_signin_session_duration: <p>Specifies whether to clear the maximum sign-in session duration on the specified IAM user's login profile. Set this value to <code>true</code> to return the setting to its unset state, so that the existing sign-in session behavior applies.</p> <p>If you set this value to <code>false</code> or omit it, the current setting is not cleared. You cannot set this value to <code>true</code> and specify <code>MaxSigninSessionDuration</code> in the same request. Clearing a setting that is already unset has no effect.</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_input_exception.InvalidInputException: <p>The request was rejected because an invalid or out-of-range value was supplied for an input parameter.</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 an IAM user
        The following command creates or changes the password for the IAM user named Bob.

        >>> client.update_login_profile(user_name='Bob', password='SomeKindOfPassword123!@#')
    """

    def _handler(
        req: "OperationRequest[capo_iam.types.update_login_profile_request.UpdateLoginProfileRequest]",
    ) -> OperationResponse[None]:
        import capo_iam._operations.aws_identity_management_v20100508.update_login_profile

        output, http_response = (
            capo_iam._operations.aws_identity_management_v20100508.update_login_profile.update_login_profile(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_iam.types.update_login_profile_request.UpdateLoginProfileRequest",
    ) -> dict[str, Any]:
        import capo_iam.types.update_login_profile_request

        return capo_iam.types.update_login_profile_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("UpdateLoginProfile", redact_input=_redact_input),
    )
    input_: capo_iam.types.update_login_profile_request.UpdateLoginProfileRequest = {
        "user_name": user_name
    }
    if password is not None:
        input_["password"] = password
    if password_reset_required is not None:
        input_["password_reset_required"] = password_reset_required
    if max_signin_session_duration is not None:
        input_["max_signin_session_duration"] = max_signin_session_duration
    if reset_max_signin_session_duration is not None:
        input_["reset_max_signin_session_duration"] = (
            reset_max_signin_session_duration
        )

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output