Skip to content

create_directory

create_directory(
    name: DirectoryName,
    password: Password,
    size: DirectorySize,
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    short_name: Optional[DirectoryShortName] = None,
    description: Optional[Description] = None,
    vpc_settings: Optional[DirectoryVpcSettings] = None,
    tags: Optional[Tags] = None,
    network_type: Optional[NetworkType] = None,
) -> CreateDirectoryResult

Creates a Simple AD directory. For more information, see Simple Active Directory in the Directory Service Admin Guide.

Before you call CreateDirectory, ensure that all of the required permissions have been explicitly granted through a policy. For details about what permissions are required to run the CreateDirectory operation, see Directory Service API Permissions: Actions, Resources, and Conditions Reference.

Parameters:

  • name (DirectoryName) –

    The fully qualified name for the directory, such as corp.example.com.

  • short_name (Optional[DirectoryShortName], default: None ) –

    The NetBIOS name of the directory, such as CORP.

  • password (Password) –

    The password for the directory administrator. The directory creation process creates a directory administrator account with the user name Administrator and this password.

    If you need to change the password for the administrator account, you can use the ResetUserPassword API call.

    The regex pattern for this string is made up of the following conditions:

    • Length (?=^.{8,64}$) – Must be between 8 and 64 characters

    AND any 3 of the following password complexity rules required by Active Directory:

    • Numbers and upper case and lowercase (?=.*\d)(?=.*[A-Z])(?=.*[a-z])

    • Numbers and special characters and lower case (?=.*\d)(?=.*[^A-Za-z0-9\s])(?=.*[a-z])

    • Special characters and upper case and lower case (?=.*[^A-Za-z0-9\s])(?=.*[A-Z])(?=.*[a-z])

    • Numbers and upper case and special characters (?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9\s])

    For additional information about how Active Directory passwords are enforced, see Password must meet complexity requirements on the Microsoft website.

  • description (Optional[Description], default: None ) –

    A description for the directory.

  • size (DirectorySize) –

    The size of the directory.

  • vpc_settings (Optional[DirectoryVpcSettings], default: None ) –

    A DirectoryVpcSettings object that contains additional information for the operation.

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

    The tags to be assigned to the Simple AD directory.

  • network_type (Optional[NetworkType], default: None ) –

    The network type for your directory. Simple AD supports IPv4 and Dual-stack only.

Raises:

Examples:

To create a Simple AD directory The following example creates a Simple AD directory.

>>> client.create_directory(name='seattle.example.com', short_name='seattle', password='Str0ngP@ssw0rd', description='Regional directory for example.com', size='Small', vpc_settings={'SubnetIds': ['subnet-ba0146de', 'subnet-bef46bc8'], 'VpcId': 'vpc-45025421'})
Source code in docs_src/capo_directory_service/_services/directory_service.py
def create_directory(
    self,
    name: "capo_directory_service.types.directory_name.DirectoryName",
    password: "capo_directory_service.types.password.Password",
    size: "capo_directory_service.types.directory_size.DirectorySize",
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    short_name: Optional[
        "capo_directory_service.types.directory_short_name.DirectoryShortName"
    ] = None,
    description: Optional[
        "capo_directory_service.types.description.Description"
    ] = None,
    vpc_settings: Optional[
        "capo_directory_service.types.directory_vpc_settings.DirectoryVpcSettings"
    ] = None,
    tags: Optional["capo_directory_service.types.tags.Tags"] = None,
    network_type: Optional[
        "capo_directory_service.types.network_type.NetworkType"
    ] = None,
) -> "capo_directory_service.types.create_directory_result.CreateDirectoryResult":
    r"""<p>Creates a Simple AD directory. For more information, see <a href="https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_simple_ad.html">Simple Active Directory</a> in the <i>Directory Service Admin Guide</i>.</p> <p>Before you call <code>CreateDirectory</code>, ensure that all of the required permissions have been explicitly granted through a policy. For details about what permissions are required to run the <code>CreateDirectory</code> operation, see <a href="http://docs.aws.amazon.com/directoryservice/latest/admin-guide/UsingWithDS_IAM_ResourcePermissions.html">Directory Service API Permissions: Actions, Resources, and Conditions Reference</a>.</p>

    Args:
        name: <p>The fully qualified name for the directory, such as <code>corp.example.com</code>.</p>
        short_name: <p>The NetBIOS name of the directory, such as <code>CORP</code>.</p>
        password: <p>The password for the directory administrator. The directory creation process creates a directory administrator account with the user name <code>Administrator</code> and this password.</p> <p>If you need to change the password for the administrator account, you can use the <a>ResetUserPassword</a> API call.</p> <p>The regex pattern for this string is made up of the following conditions:</p> <ul> <li> <p>Length (?=^.{8,64}$) – Must be between 8 and 64 characters</p> </li> </ul> <p>AND any 3 of the following password complexity rules required by Active Directory:</p> <ul> <li> <p>Numbers and upper case and lowercase (?=.*\d)(?=.*[A-Z])(?=.*[a-z])</p> </li> <li> <p>Numbers and special characters and lower case (?=.*\d)(?=.*[^A-Za-z0-9\s])(?=.*[a-z])</p> </li> <li> <p>Special characters and upper case and lower case (?=.*[^A-Za-z0-9\s])(?=.*[A-Z])(?=.*[a-z])</p> </li> <li> <p>Numbers and upper case and special characters (?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9\s])</p> </li> </ul> <p>For additional information about how Active Directory passwords are enforced, see <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements">Password must meet complexity requirements</a> on the Microsoft website.</p>
        description: <p>A description for the directory.</p>
        size: <p>The size of the directory.</p>
        vpc_settings: <p>A <a>DirectoryVpcSettings</a> object that contains additional information for the operation.</p>
        tags: <p>The tags to be assigned to the Simple AD directory.</p>
        network_type: <p>The network type for your directory. Simple AD supports IPv4 and Dual-stack only.</p>

    Raises:
        capo_directory_service.errors.client_exception.ClientException: <p>A client exception has occurred.</p>
        capo_directory_service.errors.directory_limit_exceeded_exception.DirectoryLimitExceededException: <p>The maximum number of directories in the region has been reached. You can use the <a>GetDirectoryLimits</a> operation to determine your directory limits in the region.</p>
        capo_directory_service.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more parameters are not valid.</p>
        capo_directory_service.errors.service_exception.ServiceException: <p>An exception has occurred in Directory Service.</p>
        capo_directory_service.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a Simple AD directory
        The following example creates a Simple AD directory.

        >>> client.create_directory(name='seattle.example.com', short_name='seattle', password='Str0ngP@ssw0rd', description='Regional directory for example.com', size='Small', vpc_settings={'SubnetIds': ['subnet-ba0146de', 'subnet-bef46bc8'], 'VpcId': 'vpc-45025421'})
    """

    def _handler(
        req: "OperationRequest[capo_directory_service.types.create_directory_request.CreateDirectoryRequest]",
    ) -> OperationResponse[
        "capo_directory_service.types.create_directory_result.CreateDirectoryResult"
    ]:
        import capo_directory_service._operations.directory_service_20150416.create_directory

        output, http_response = (
            capo_directory_service._operations.directory_service_20150416.create_directory.create_directory(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_directory_service.types.create_directory_request.CreateDirectoryRequest",
    ) -> dict[str, Any]:
        import capo_directory_service.types.create_directory_request

        return (
            capo_directory_service.types.create_directory_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateDirectory", redact_input=_redact_input),
    )
    input_: capo_directory_service.types.create_directory_request.CreateDirectoryRequest = {
        "name": name,
        "password": password,
        "size": size,
    }
    if short_name is not None:
        input_["short_name"] = short_name
    if description is not None:
        input_["description"] = description
    if vpc_settings is not None:
        input_["vpc_settings"] = vpc_settings
    if tags is not None:
        input_["tags"] = tags
    if network_type is not None:
        input_["network_type"] = network_type

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