Creates a password for the specified IAM user. A password allows an IAM user to access Amazon Web Services services through the Amazon Web Services Management Console.
You can use the CLI, the Amazon Web Services API, or the Users page in the IAM console to create a password for any IAM user. Use ChangePassword to update your own existing password in the My Security Credentials page in the Amazon Web Services Management Console.
For more information about managing passwords, see Managing passwords in the IAM User Guide.
Parameters:
-
user_name
(Optional[userNameType], default:
None
)
–
The name of the IAM user to create a password for. The user must already exist.
This parameter is optional. If no user name is included, it defaults to the principal making the request. When you make this request with root user credentials, you must use an AssumeRoot session to omit the user name.
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 user.
This parameter must be omitted when you make the request with an AssumeRoot session. It is required in all other cases.
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.
-
password_reset_required
(Optional[booleanType], default:
None
)
–
Specifies whether the user is required to set a new password on next sign-in.
Raises:
-
EntityAlreadyExistsException
–
The request was rejected because it attempted to create a resource that already exists.
-
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 create an instance profile
The following command changes IAM user Bob's password and sets the flag that required Bob to change the password the next time he signs in.
>>> client.create_login_profile(user_name='Bob', password='h]6EszR}vJ*m', password_reset_required=True)
Source code in docs_src/capo_iam/_services/iam.py
| def create_login_profile(
self,
*,
config_overrides: Optional[IAMClientConfig] = None,
user_name: Optional["capo_iam.types.user_name_type.userNameType"] = None,
password: Optional["capo_iam.types.password_type.passwordType"] = None,
password_reset_required: Optional[
"capo_iam.types.boolean_type.booleanType"
] = None,
) -> "capo_iam.types.create_login_profile_response.CreateLoginProfileResponse":
r"""<p>Creates a password for the specified IAM user. A password allows an IAM user to access Amazon Web Services services through the Amazon Web Services Management Console.</p> <p>You can use the CLI, the Amazon Web Services API, or the <b>Users</b> page in the IAM console to create a password for any IAM user. Use <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_ChangePassword.html">ChangePassword</a> to update your own existing password in the <b>My Security Credentials</b> page in the Amazon Web Services Management Console.</p> <p>For more information about managing 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 IAM user to create a password for. The user must already exist.</p> <p>This parameter is optional. If no user name is included, it defaults to the principal making the request. When you make this request with root user credentials, you must use an <a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoot.html">AssumeRoot</a> session to omit the user name.</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 user.</p> <p>This parameter must be omitted when you make the request with an <a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoot.html">AssumeRoot</a> session. It is required in all other cases.</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>
password_reset_required: <p>Specifies whether the user is required to set a new password on next sign-in.</p>
Raises:
capo_iam.errors.entity_already_exists_exception.EntityAlreadyExistsException: <p>The request was rejected because it attempted to create a resource that already exists.</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 create an instance profile
The following command changes IAM user Bob's password and sets the flag that required Bob to change the password the next time he signs in.
>>> client.create_login_profile(user_name='Bob', password='h]6EszR}vJ*m', password_reset_required=True)
"""
def _handler(
req: "OperationRequest[capo_iam.types.create_login_profile_request.CreateLoginProfileRequest]",
) -> OperationResponse[
"capo_iam.types.create_login_profile_response.CreateLoginProfileResponse"
]:
import capo_iam._operations.aws_identity_management_v20100508.create_login_profile
output, http_response = (
capo_iam._operations.aws_identity_management_v20100508.create_login_profile.create_login_profile(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_iam.types.create_login_profile_request.CreateLoginProfileRequest",
) -> dict[str, Any]:
import capo_iam.types.create_login_profile_request
return capo_iam.types.create_login_profile_request.redact_sensitive(input_)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("CreateLoginProfile", redact_input=_redact_input),
)
input_: capo_iam.types.create_login_profile_request.CreateLoginProfileRequest = {}
if user_name is not None:
input_["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
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|