Skip to content

create_user

create_user(
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    user_id: Optional[UserId] = None,
    user_name: Optional[UserName] = None,
    engine: Optional[EngineType] = None,
    passwords: Optional[PasswordListInput] = None,
    access_string: Optional[AccessString] = None,
    no_password_required: Optional[BooleanOptional] = None,
    tags: Optional[TagList] = None,
    authentication_mode: Optional[AuthenticationMode] = None,
) -> User

For Valkey engine version 7.2 onwards and Redis OSS 6.0 to 7.1: Creates a user. For more information, see Using Role Based Access Control (RBAC).

Parameters:

  • user_id (Optional[UserId], default: None ) –

    The ID of the user. This value is stored as a lowercase string.

  • user_name (Optional[UserName], default: None ) –

    The username of the user.

  • engine (Optional[EngineType], default: None ) –

    The options are valkey or redis.

  • passwords (Optional[PasswordListInput], default: None ) –

    Passwords used for this user. You can create up to two passwords for each user.

  • access_string (Optional[AccessString], default: None ) –

    Access permissions string used for this user.

  • no_password_required (Optional[BooleanOptional], default: None ) –

    Indicates a password is not required for this user.

  • tags (Optional[TagList], default: None ) –

    A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.

  • authentication_mode (Optional[AuthenticationMode], default: None ) –

    Specifies how to authenticate the user.

Raises:

Source code in docs_src/capo_elasticache/_services/elasti_cache.py
def create_user(
    self,
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    user_id: Optional["capo_elasticache.types.user_id.UserId"] = None,
    user_name: Optional["capo_elasticache.types.user_name.UserName"] = None,
    engine: Optional["capo_elasticache.types.engine_type.EngineType"] = None,
    passwords: Optional[
        "capo_elasticache.types.password_list_input.PasswordListInput"
    ] = None,
    access_string: Optional[
        "capo_elasticache.types.access_string.AccessString"
    ] = None,
    no_password_required: Optional[
        "capo_elasticache.types.boolean_optional.BooleanOptional"
    ] = None,
    tags: Optional["capo_elasticache.types.tag_list.TagList"] = None,
    authentication_mode: Optional[
        "capo_elasticache.types.authentication_mode.AuthenticationMode"
    ] = None,
) -> "capo_elasticache.types.user.User":
    """<p>For Valkey engine version 7.2 onwards and Redis OSS 6.0 to 7.1: Creates a user. For more information, see <a href="http://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Clusters.RBAC.html">Using Role Based Access Control (RBAC)</a>.</p>

    Args:
        user_id: <p>The ID of the user. This value is stored as a lowercase string.</p>
        user_name: <p>The username of the user.</p>
        engine: <p>The options are valkey or redis. </p>
        passwords: <p>Passwords used for this user. You can create up to two passwords for each user.</p>
        access_string: <p>Access permissions string used for this user.</p>
        no_password_required: <p>Indicates a password is not required for this user.</p>
        tags: <p>A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.</p>
        authentication_mode: <p>Specifies how to authenticate the user.</p>

    Raises:
        capo_elasticache.errors.duplicate_user_name_fault.DuplicateUserNameFault: <p>A user with this username already exists.</p>
        capo_elasticache.errors.invalid_parameter_combination_exception.InvalidParameterCombinationException: <p>Two or more incompatible parameters were specified.</p>
        capo_elasticache.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value for a parameter is invalid.</p>
        capo_elasticache.errors.service_linked_role_not_found_fault.ServiceLinkedRoleNotFoundFault: <p>The specified service linked role (SLR) was not found.</p>
        capo_elasticache.errors.tag_quota_per_resource_exceeded.TagQuotaPerResourceExceeded: <p>The request cannot be processed because it would cause the resource to have more than the allowed number of tags. The maximum number of tags permitted on a resource is 50.</p>
        capo_elasticache.errors.user_already_exists_fault.UserAlreadyExistsFault: <p>A user with this ID already exists.</p>
        capo_elasticache.errors.user_quota_exceeded_fault.UserQuotaExceededFault: <p>The quota of users has been exceeded.</p>
        capo_elasticache.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_elasticache.types.create_user_message.CreateUserMessage]",
    ) -> OperationResponse["capo_elasticache.types.user.User"]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.create_user

        output, http_response = (
            capo_elasticache._operations.amazon_elasti_cache_v9.create_user.create_user(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateUser")
    )
    input_: capo_elasticache.types.create_user_message.CreateUserMessage = {}
    if user_id is not None:
        input_["user_id"] = user_id
    if user_name is not None:
        input_["user_name"] = user_name
    if engine is not None:
        input_["engine"] = engine
    if passwords is not None:
        input_["passwords"] = passwords
    if access_string is not None:
        input_["access_string"] = access_string
    if no_password_required is not None:
        input_["no_password_required"] = no_password_required
    if tags is not None:
        input_["tags"] = tags
    if authentication_mode is not None:
        input_["authentication_mode"] = authentication_mode

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