Skip to content

create_domain

create_domain(
    domain_name: DomainName,
    *,
    config_overrides: Optional[OpenSearchClientConfig] = None,
    engine_version: Optional[VersionString] = None,
    cluster_config: Optional[ClusterConfig] = None,
    ebs_options: Optional[EBSOptions] = None,
    access_policies: Optional[PolicyDocument] = None,
    ip_address_type: Optional[IPAddressType] = None,
    snapshot_options: Optional[SnapshotOptions] = None,
    vpc_options: Optional[VPCOptions] = None,
    cognito_options: Optional[CognitoOptions] = None,
    encryption_at_rest_options: Optional[EncryptionAtRestOptions] = None,
    node_to_node_encryption_options: Optional[NodeToNodeEncryptionOptions] = None,
    advanced_options: Optional[AdvancedOptions] = None,
    log_publishing_options: Optional[LogPublishingOptions] = None,
    domain_endpoint_options: Optional[DomainEndpointOptions] = None,
    advanced_security_options: Optional[AdvancedSecurityOptionsInput] = None,
    identity_center_options: Optional[IdentityCenterOptionsInput] = None,
    tag_list: Optional[TagList] = None,
    auto_tune_options: Optional[AutoTuneOptionsInput] = None,
    off_peak_window_options: Optional[OffPeakWindowOptions] = None,
    software_update_options: Optional[SoftwareUpdateOptions] = None,
    aiml_options: Optional[AIMLOptionsInput] = None,
    deployment_strategy_options: Optional[DeploymentStrategyOptions] = None,
    automated_snapshot_pause_options: Optional[
        AutomatedSnapshotPauseRequestOptions
    ] = None,
    use_case: Optional[DomainUseCase] = None,
    engine_mode: Optional[EngineMode] = None,
) -> CreateDomainResponse

Creates an Amazon OpenSearch Service domain. For more information, see Creating and managing Amazon OpenSearch Service domains.

Parameters:

  • domain_name (DomainName) –

    Name of the OpenSearch Service domain to create. Domain names are unique across the domains owned by an account within an Amazon Web Services Region.

  • engine_version (Optional[VersionString], default: None ) –

    String of format Elasticsearch_X.Y or OpenSearch_X.Y to specify the engine version for the OpenSearch Service domain. For example, OpenSearch_1.0 or Elasticsearch_7.9. For more information, see Creating and managing Amazon OpenSearch Service domains.

  • cluster_config (Optional[ClusterConfig], default: None ) –

    Container for the cluster configuration of a domain.

  • ebs_options (Optional[EBSOptions], default: None ) –

    Container for the parameters required to enable EBS-based storage for an OpenSearch Service domain.

  • access_policies (Optional[PolicyDocument], default: None ) –

    Identity and Access Management (IAM) policy document specifying the access policies for the new domain.

  • ip_address_type (Optional[IPAddressType], default: None ) –

    Specify either dual stack or IPv4 as your IP address type. Dual stack allows you to share domain resources across IPv4 and IPv6 address types, and is the recommended option. If you set your IP address type to dual stack, you can't change your address type later.

  • snapshot_options (Optional[SnapshotOptions], default: None ) –

    DEPRECATED. Container for the parameters required to configure automated snapshots of domain indexes.

  • vpc_options (Optional[VPCOptions], default: None ) –

    Container for the values required to configure VPC access domains. If you don't specify these values, OpenSearch Service creates the domain with a public endpoint. For more information, see Launching your Amazon OpenSearch Service domains using a VPC.

  • cognito_options (Optional[CognitoOptions], default: None ) –

    Key-value pairs to configure Amazon Cognito authentication. For more information, see Configuring Amazon Cognito authentication for OpenSearch Dashboards.

  • encryption_at_rest_options (Optional[EncryptionAtRestOptions], default: None ) –

    Key-value pairs to enable encryption at rest.

  • node_to_node_encryption_options (Optional[NodeToNodeEncryptionOptions], default: None ) –

    Enables node-to-node encryption.

  • advanced_options (Optional[AdvancedOptions], default: None ) –

    Key-value pairs to specify advanced configuration options. The following key-value pairs are supported:

    • "rest.action.multi.allow_explicit_index": "true" | "false" - Note the use of a string rather than a boolean. Specifies whether explicit references to indexes are allowed inside the body of HTTP requests. If you want to configure access policies for domain sub-resources, such as specific indexes and domain APIs, you must disable this property. Default is true.

    • "indices.fielddata.cache.size": "80" - Note the use of a string rather than a boolean. Specifies the percentage of heap space allocated to field data. Default is unbounded.

    • "indices.query.bool.max_clause_count": "1024" - Note the use of a string rather than a boolean. Specifies the maximum number of clauses allowed in a Lucene boolean query. Default is 1,024. Queries with more than the permitted number of clauses result in a TooManyClauses error.

    • "override_main_response_version": "true" | "false" - Note the use of a string rather than a boolean. Specifies whether the domain reports its version as 7.10 to allow Elasticsearch OSS clients and plugins to continue working with it. Default is false when creating a domain and true when upgrading a domain.

    For more information, see Advanced cluster parameters.

  • log_publishing_options (Optional[LogPublishingOptions], default: None ) –

    Key-value pairs to configure log publishing.

  • domain_endpoint_options (Optional[DomainEndpointOptions], default: None ) –

    Additional options for the domain endpoint, such as whether to require HTTPS for all traffic.

  • advanced_security_options (Optional[AdvancedSecurityOptionsInput], default: None ) –

    Options for fine-grained access control.

  • identity_center_options (Optional[IdentityCenterOptionsInput], default: None ) –

    Configuration options for enabling and managing IAM Identity Center integration within a domain.

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

    List of tags to add to the domain upon creation.

  • auto_tune_options (Optional[AutoTuneOptionsInput], default: None ) –

    Options for Auto-Tune.

  • off_peak_window_options (Optional[OffPeakWindowOptions], default: None ) –

    Specifies a daily 10-hour time block during which OpenSearch Service can perform configuration changes on the domain, including service software updates and Auto-Tune enhancements that require a blue/green deployment. If no options are specified, the default start time of 10:00 P.M. local time (for the Region that the domain is created in) is used.

  • software_update_options (Optional[SoftwareUpdateOptions], default: None ) –

    Software update options for the domain.

  • aiml_options (Optional[AIMLOptionsInput], default: None ) –

    Options for all machine learning features for the specified domain.

  • deployment_strategy_options (Optional[DeploymentStrategyOptions], default: None ) –

    Specifies the deployment strategy options for the domain.

  • automated_snapshot_pause_options (Optional[AutomatedSnapshotPauseRequestOptions], default: None ) –

    Specifies the automated snapshot pause options for the domain.

    Suspending snapshots reduces data protection. You cannot restore your domain to points in time when snapshots are suspended. Use this feature only for short-term operational needs such as migrations or maintenance windows.

    Maximum suspension duration: 3 days.

  • use_case (Optional[DomainUseCase], default: None ) –

    The primary use case for the domain. For valid values, see DomainUseCase.

  • engine_mode (Optional[EngineMode], default: None ) –

    The engine mode for the domain. For valid values and requirements, see EngineMode.

Raises:

  • BaseException –

    An error occurred while processing the request.

  • DisabledOperationException –

    An error occured because the client wanted to access an unsupported operation.

  • InternalException –

    Request processing failed because of an unknown error, exception, or internal failure.

  • InvalidTypeException –

    An exception for trying to create or access a sub-resource that's either invalid or not supported.

  • LimitExceededException –

    An exception for trying to create more than the allowed number of resources or sub-resources.

  • ResourceAlreadyExistsException –

    An exception for creating a resource that already exists.

  • ValidationException –

    An exception for accessing or deleting a resource that doesn't exist.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_opensearch/_services/open_search.py
def create_domain(
    self,
    domain_name: "capo_opensearch.types.domain_name.DomainName",
    *,
    config_overrides: Optional[OpenSearchClientConfig] = None,
    engine_version: Optional[
        "capo_opensearch.types.version_string.VersionString"
    ] = None,
    cluster_config: Optional[
        "capo_opensearch.types.cluster_config.ClusterConfig"
    ] = None,
    ebs_options: Optional["capo_opensearch.types.ebs_options.EBSOptions"] = None,
    access_policies: Optional[
        "capo_opensearch.types.policy_document.PolicyDocument"
    ] = None,
    ip_address_type: Optional[
        "capo_opensearch.types.ip_address_type.IPAddressType"
    ] = None,
    snapshot_options: Optional[
        "capo_opensearch.types.snapshot_options.SnapshotOptions"
    ] = None,
    vpc_options: Optional["capo_opensearch.types.vpc_options.VPCOptions"] = None,
    cognito_options: Optional[
        "capo_opensearch.types.cognito_options.CognitoOptions"
    ] = None,
    encryption_at_rest_options: Optional[
        "capo_opensearch.types.encryption_at_rest_options.EncryptionAtRestOptions"
    ] = None,
    node_to_node_encryption_options: Optional[
        "capo_opensearch.types.node_to_node_encryption_options.NodeToNodeEncryptionOptions"
    ] = None,
    advanced_options: Optional[
        "capo_opensearch.types.advanced_options.AdvancedOptions"
    ] = None,
    log_publishing_options: Optional[
        "capo_opensearch.types.log_publishing_options.LogPublishingOptions"
    ] = None,
    domain_endpoint_options: Optional[
        "capo_opensearch.types.domain_endpoint_options.DomainEndpointOptions"
    ] = None,
    advanced_security_options: Optional[
        "capo_opensearch.types.advanced_security_options_input.AdvancedSecurityOptionsInput"
    ] = None,
    identity_center_options: Optional[
        "capo_opensearch.types.identity_center_options_input.IdentityCenterOptionsInput"
    ] = None,
    tag_list: Optional["capo_opensearch.types.tag_list.TagList"] = None,
    auto_tune_options: Optional[
        "capo_opensearch.types.auto_tune_options_input.AutoTuneOptionsInput"
    ] = None,
    off_peak_window_options: Optional[
        "capo_opensearch.types.off_peak_window_options.OffPeakWindowOptions"
    ] = None,
    software_update_options: Optional[
        "capo_opensearch.types.software_update_options.SoftwareUpdateOptions"
    ] = None,
    aiml_options: Optional[
        "capo_opensearch.types.aiml_options_input.AIMLOptionsInput"
    ] = None,
    deployment_strategy_options: Optional[
        "capo_opensearch.types.deployment_strategy_options.DeploymentStrategyOptions"
    ] = None,
    automated_snapshot_pause_options: Optional[
        "capo_opensearch.types.automated_snapshot_pause_request_options.AutomatedSnapshotPauseRequestOptions"
    ] = None,
    use_case: Optional[
        "capo_opensearch.types.domain_use_case.DomainUseCase"
    ] = None,
    engine_mode: Optional["capo_opensearch.types.engine_mode.EngineMode"] = None,
) -> "capo_opensearch.types.create_domain_response.CreateDomainResponse":
    """<p>Creates an Amazon OpenSearch Service domain. For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html">Creating and managing Amazon OpenSearch Service domains</a>.</p>

    Args:
        domain_name: <p>Name of the OpenSearch Service domain to create. Domain names are unique across the domains owned by an account within an Amazon Web Services Region.</p>
        engine_version: <p>String of format Elasticsearch_X.Y or OpenSearch_X.Y to specify the engine version for the OpenSearch Service domain. For example, <code>OpenSearch_1.0</code> or <code>Elasticsearch_7.9</code>. For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html#createdomains">Creating and managing Amazon OpenSearch Service domains</a>.</p>
        cluster_config: <p>Container for the cluster configuration of a domain.</p>
        ebs_options: <p>Container for the parameters required to enable EBS-based storage for an OpenSearch Service domain.</p>
        access_policies: <p>Identity and Access Management (IAM) policy document specifying the access policies for the new domain.</p>
        ip_address_type: <p>Specify either dual stack or IPv4 as your IP address type. Dual stack allows you to share domain resources across IPv4 and IPv6 address types, and is the recommended option. If you set your IP address type to dual stack, you can't change your address type later.</p>
        snapshot_options: <p>DEPRECATED. Container for the parameters required to configure automated snapshots of domain indexes.</p>
        vpc_options: <p>Container for the values required to configure VPC access domains. If you don't specify these values, OpenSearch Service creates the domain with a public endpoint. For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/vpc.html">Launching your Amazon OpenSearch Service domains using a VPC</a>.</p>
        cognito_options: <p>Key-value pairs to configure Amazon Cognito authentication. For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/cognito-auth.html">Configuring Amazon Cognito authentication for OpenSearch Dashboards</a>.</p>
        encryption_at_rest_options: <p>Key-value pairs to enable encryption at rest.</p>
        node_to_node_encryption_options: <p>Enables node-to-node encryption.</p>
        advanced_options: <p>Key-value pairs to specify advanced configuration options. The following key-value pairs are supported:</p> <ul> <li> <p> <code>"rest.action.multi.allow_explicit_index": "true" | "false"</code> - Note the use of a string rather than a boolean. Specifies whether explicit references to indexes are allowed inside the body of HTTP requests. If you want to configure access policies for domain sub-resources, such as specific indexes and domain APIs, you must disable this property. Default is true.</p> </li> <li> <p> <code>"indices.fielddata.cache.size": "80" </code> - Note the use of a string rather than a boolean. Specifies the percentage of heap space allocated to field data. Default is unbounded.</p> </li> <li> <p> <code>"indices.query.bool.max_clause_count": "1024"</code> - Note the use of a string rather than a boolean. Specifies the maximum number of clauses allowed in a Lucene boolean query. Default is 1,024. Queries with more than the permitted number of clauses result in a <code>TooManyClauses</code> error.</p> </li> <li> <p> <code>"override_main_response_version": "true" | "false"</code> - Note the use of a string rather than a boolean. Specifies whether the domain reports its version as 7.10 to allow Elasticsearch OSS clients and plugins to continue working with it. Default is false when creating a domain and true when upgrading a domain.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html#createdomain-configure-advanced-options">Advanced cluster parameters</a>.</p>
        log_publishing_options: <p>Key-value pairs to configure log publishing.</p>
        domain_endpoint_options: <p>Additional options for the domain endpoint, such as whether to require HTTPS for all traffic.</p>
        advanced_security_options: <p>Options for fine-grained access control.</p>
        identity_center_options: <p>Configuration options for enabling and managing IAM Identity Center integration within a domain.</p>
        tag_list: <p>List of tags to add to the domain upon creation.</p>
        auto_tune_options: <p>Options for Auto-Tune.</p>
        off_peak_window_options: <p>Specifies a daily 10-hour time block during which OpenSearch Service can perform configuration changes on the domain, including service software updates and Auto-Tune enhancements that require a blue/green deployment. If no options are specified, the default start time of 10:00 P.M. local time (for the Region that the domain is created in) is used.</p>
        software_update_options: <p>Software update options for the domain.</p>
        aiml_options: <p>Options for all machine learning features for the specified domain.</p>
        deployment_strategy_options: <p>Specifies the deployment strategy options for the domain.</p>
        automated_snapshot_pause_options: <p>Specifies the automated snapshot pause options for the domain.</p> <important> <p>Suspending snapshots reduces data protection. You cannot restore your domain to points in time when snapshots are suspended. Use this feature only for short-term operational needs such as migrations or maintenance windows.</p> </important> <p>Maximum suspension duration: 3 days.</p>
        use_case: <p>The primary use case for the domain. For valid values, see <code>DomainUseCase</code>.</p>
        engine_mode: <p>The engine mode for the domain. For valid values and requirements, see <code>EngineMode</code>.</p>

    Raises:
        capo_opensearch.errors.base_exception.BaseException: <p>An error occurred while processing the request.</p>
        capo_opensearch.errors.disabled_operation_exception.DisabledOperationException: <p>An error occured because the client wanted to access an unsupported operation.</p>
        capo_opensearch.errors.internal_exception.InternalException: <p>Request processing failed because of an unknown error, exception, or internal failure.</p>
        capo_opensearch.errors.invalid_type_exception.InvalidTypeException: <p>An exception for trying to create or access a sub-resource that's either invalid or not supported.</p>
        capo_opensearch.errors.limit_exceeded_exception.LimitExceededException: <p>An exception for trying to create more than the allowed number of resources or sub-resources.</p>
        capo_opensearch.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>An exception for creating a resource that already exists.</p>
        capo_opensearch.errors.validation_exception.ValidationException: <p>An exception for accessing or deleting a resource that doesn't exist.</p>
        capo_opensearch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_opensearch.types.create_domain_request.CreateDomainRequest]",
    ) -> OperationResponse[
        "capo_opensearch.types.create_domain_response.CreateDomainResponse"
    ]:
        import capo_opensearch._operations.amazon_open_search_service.create_domain

        output, http_response = (
            capo_opensearch._operations.amazon_open_search_service.create_domain.create_domain(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_opensearch.types.create_domain_request.CreateDomainRequest",
    ) -> dict[str, Any]:
        import capo_opensearch.types.create_domain_request

        return capo_opensearch.types.create_domain_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateDomain", redact_input=_redact_input),
    )
    input_: capo_opensearch.types.create_domain_request.CreateDomainRequest = {
        "domain_name": domain_name
    }
    if engine_version is not None:
        input_["engine_version"] = engine_version
    if cluster_config is not None:
        input_["cluster_config"] = cluster_config
    if ebs_options is not None:
        input_["ebs_options"] = ebs_options
    if access_policies is not None:
        input_["access_policies"] = access_policies
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type
    if snapshot_options is not None:
        input_["snapshot_options"] = snapshot_options
    if vpc_options is not None:
        input_["vpc_options"] = vpc_options
    if cognito_options is not None:
        input_["cognito_options"] = cognito_options
    if encryption_at_rest_options is not None:
        input_["encryption_at_rest_options"] = encryption_at_rest_options
    if node_to_node_encryption_options is not None:
        input_["node_to_node_encryption_options"] = node_to_node_encryption_options
    if advanced_options is not None:
        input_["advanced_options"] = advanced_options
    if log_publishing_options is not None:
        input_["log_publishing_options"] = log_publishing_options
    if domain_endpoint_options is not None:
        input_["domain_endpoint_options"] = domain_endpoint_options
    if advanced_security_options is not None:
        input_["advanced_security_options"] = advanced_security_options
    if identity_center_options is not None:
        input_["identity_center_options"] = identity_center_options
    if tag_list is not None:
        input_["tag_list"] = tag_list
    if auto_tune_options is not None:
        input_["auto_tune_options"] = auto_tune_options
    if off_peak_window_options is not None:
        input_["off_peak_window_options"] = off_peak_window_options
    if software_update_options is not None:
        input_["software_update_options"] = software_update_options
    if aiml_options is not None:
        input_["aiml_options"] = aiml_options
    if deployment_strategy_options is not None:
        input_["deployment_strategy_options"] = deployment_strategy_options
    if automated_snapshot_pause_options is not None:
        input_["automated_snapshot_pause_options"] = (
            automated_snapshot_pause_options
        )
    if use_case is not None:
        input_["use_case"] = use_case
    if engine_mode is not None:
        input_["engine_mode"] = engine_mode

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