# Domain

Provides an Amazon OpenSearch Service domain.

Extends: Construct › Resource › Domain
Implements: IResource, IConnectable, IDomain, IEnvironmentAware, IDomainRef, IConstruct, IDependable

- CloudFormation: [`AWS::OpenSearchService::Domain`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-opensearchservice-domain.html)
- L1 type: [`CfnDomain`](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.CfnDomain.html)
- Source: [`aws-opensearchservice/lib/domain.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts#L1402)
- Type last changed: v2.227.0 · 21 Nov 2025

## Example

```ts
const domain = new Domain(this, 'Domain', {
  version: EngineVersion.OPENSEARCH_1_0,
  ebs: {
    volumeSize: 100,
    volumeType: ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
  },
  nodeToNodeEncryption: true,
  encryptionAtRest: {
    enabled: true,
  },
});
```

## Initializer

```ts
new Domain(scope: Construct, id: string, props: DomainProps)
```

## Construct Props

- `accessPolicies`: [PolicyStatement](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyStatement.html)[] — Domain access policies.

  **Default:** No access policies.

- `advancedOptions`: { [key: string]: string } — Additional options to specify for the Amazon OpenSearch Service domain.

  **Default:** no advanced options are specified

- `automatedSnapshotStartHour`: number — The hour in UTC during which the service takes an automated daily snapshot of the indices in the Amazon OpenSearch Service domain.

  **Default:** Hourly automated snapshots not used

  Only applies for Elasticsearch versions
  below 5.3.

- `capacity`: [CapacityConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.CapacityConfig.html) — The cluster capacity configuration for the Amazon OpenSearch Service domain.

  **Default:** 1 r5.large.search data node; no dedicated master nodes.

- `cognitoDashboardsAuth`: [CognitoOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.CognitoOptions.html) — Configures Amazon OpenSearch Service to use Amazon Cognito authentication for OpenSearch Dashboards.

  **Default:** Cognito not used for authentication to OpenSearch Dashboards.

- `coldStorageEnabled`: boolean = undefined — Whether to enable or disable cold storage on the domain.

  You must enable UltraWarm storage to enable cold storage.

- `customEndpoint`: [CustomEndpointOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.CustomEndpointOptions.html) — To configure a custom domain configure these options.

  **Default:** no custom domain endpoint will be configured

  If you specify a Route53 hosted zone it will create a CNAME record and use DNS validation for the certificate

- `domainName`: string — Enforces a particular physical domain name.

  **Default:** A name will be auto-generated.

- `ebs`: [EbsOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.EbsOptions.html) — The configurations of Amazon Elastic Block Store (Amazon EBS) volumes that are attached to data nodes in the Amazon OpenSearch Service domain.

  **Default:** 10 GiB General Purpose (SSD) volumes per node.

- `enableAutoSoftwareUpdate`: boolean = false — Specifies whether automatic service software updates are enabled for the domain.

- `enableVersionUpgrade`: boolean = false — To upgrade an Amazon OpenSearch Service domain to a new version, rather than replacing the entire domain resource, use the EnableVersionUpgrade update policy.

- `encryptionAtRest`: [EncryptionAtRestOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.EncryptionAtRestOptions.html) — Encryption at rest options for the cluster.

  **Default:** No encryption at rest

- `enforceHttps`: boolean = false — True to require that all traffic to the domain arrive over HTTPS.

- `fineGrainedAccessControl`: [AdvancedSecurityOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.AdvancedSecurityOptions.html) — Specifies options for fine-grained access control.

  **Default:** fine-grained access control is disabled

  Requires Elasticsearch version 6.7 or later or OpenSearch version 1.0 or later. Enabling fine-grained access control
  also requires encryption of data at rest and node-to-node encryption, along with
  enforced HTTPS.

- `ipAddressType`: [IpAddressType](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.IpAddressType.html) = IpAddressType.IPV4 — 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.

- `logging`: [LoggingOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.LoggingOptions.html) — Configuration log publishing configuration options.

  **Default:** No logs are published

- `nodeToNodeEncryption`: boolean — Specify true to enable node to node encryption.

  **Default:** Node to node encryption is not enabled.

  Requires Elasticsearch version 6.0 or later or OpenSearch version 1.0 or later.

- `offPeakWindowEnabled`: boolean — Options for enabling a domain's off-peak window, during which OpenSearch Service can perform mandatory configuration changes on the domain.

  **Default:** Disabled for domains created before February 16, 2023. Enabled for domains created after. Enabled if `offPeakWindowStart` is set.

  Off-peak windows were introduced on February 16, 2023.
  All domains created before this date have the off-peak window disabled by default.
  You must manually enable and configure the off-peak window for these domains.
  All domains created after this date will have the off-peak window enabled by default.
  You can't disable the off-peak window for a domain after it's enabled.

- `offPeakWindowStart`: [WindowStartTime](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.WindowStartTime.html) — Start time for the off-peak window, in Coordinated Universal Time (UTC).

  **Default:** 10:00 P.M. local time

  The window length will always be 10 hours, so you can't specify an end time.
  For example, if you specify 11:00 P.M. UTC as a start time, the end time will automatically be set to 9:00 A.M.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.RETAIN — Policy to apply when the domain is removed from the stack.

- `s3VectorsEngineEnabled`: boolean — Whether to enable S3 vectors engine.

  **Default:** undefined - AWS OpenSearch Service default is false

  This feature allows you to offload vector data to Amazon S3 while maintaining sub-second vector search capabilities at low cost.

  Requirements:
  - OpenSearch version 2.19 or later
  - OpenSearch Optimized instance types (OR*, OM*, OI*) for data nodes
  - Encryption at rest must be enabled

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — The list of security groups that are associated with the VPC endpoints for the domain.

  **Default:** One new security group is created.

  Only used if `vpc` is specified.

- `suppressLogsResourcePolicy`: boolean = false — Specify whether to create a CloudWatch Logs resource policy or not.

  When logging is enabled for the domain, a CloudWatch Logs resource policy is created by default.
  However, CloudWatch Logs supports only 10 resource policies per region.
  If you enable logging for several domains, it may hit the quota and cause an error.
  By setting this property to true, creating a resource policy is suppressed, allowing you to avoid this problem.

  If you set this option to true, you must create a resource policy before deployment.

- `tlsSecurityPolicy`: [TLSSecurityPolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.TLSSecurityPolicy.html) = TLSSecurityPolicy.TLS_1_2 — The minimum TLS version required for traffic to the domain.

- `useLatestServiceSoftwareForBlueGreen`: boolean — Specifies whether the domain should use the latest service software version during a blue/green deployment.

  **Default:** no value is set and the service default is used

  If enabled, the domain will automatically use the latest available service software when a blue/green
  deployment is triggered.

- `useUnsignedBasicAuth`: boolean = false — Configures the domain so that unsigned basic auth is enabled.

  If no master user is provided a default master user
  with username `admin` and a dynamically generated password stored in KMS is created. The password can be retrieved
  by getting `masterUserPassword` from the domain instance.

  Setting this to true will also add an access policy that allows unsigned
  access, enable node to node encryption, encryption at rest. If conflicting
  settings are encountered (like disabling encryption at rest) enabling this
  setting will cause a failure.

- `version`: [EngineVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.EngineVersion.html) (required) — The Elasticsearch/OpenSearch version that your domain will leverage.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) — Place the domain inside this VPC.

  **Default:** Domain is not placed in a VPC.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html)[] — The specific vpc subnets the domain will be placed in.

  **Default:** All private subnets.

  You must provide one subnet for each Availability Zone
  that your domain uses. For example, you must specify three subnet IDs for a three Availability Zone
  domain.

  Only used if `vpc` is specified.

- `zoneAwareness`: [ZoneAwarenessConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.ZoneAwarenessConfig.html) — The cluster zone awareness configuration for the Amazon OpenSearch Service domain.

  **Default:** no zone awareness (1 AZ)

## Properties

- `appLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — Log group that application logs are logged to.

- `auditLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — Log group that audit logs are logged to.

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — Manages network connections to the domain.

  This will throw an error in case the domain
  is not placed inside a VPC.

- `domainArn`: string — Arn of the Amazon OpenSearch Service domain.

- `domainEndpoint`: string — Endpoint of the Amazon OpenSearch Service domain.

- `domainId`: string — Identifier of the Amazon OpenSearch Service domain.

- `domainName`: string — Domain name of the Amazon OpenSearch Service domain.

- `domainRef`: [DomainReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_opensearchservice.DomainReference.html) — A reference to a Domain resource.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `grants`: [DomainGrants](/cdk/api/v2/docs/aws-cdk-lib.aws_opensearchservice.DomainGrants.html) — Collection of grant methods for a Domain.

- `masterUserPassword`: [SecretValue](/cdk/api/v2/docs/aws-cdk-lib.SecretValue.html) — Master user password if fine grained access control is configured.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `slowIndexLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — Log group that slow indices are logged to.

- `slowSearchLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — Log group that slow searches are logged to.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addAccessPolicies(...accessPolicyStatements: PolicyStatement[]): void` — Add policy statements to the domain access policy.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromDomainAttributes(scope: Construct, id: string, attrs: DomainAttributes): IDomain` (static) — Creates a domain construct that represents an external domain.

  **Parameters**

  - `scope` — The parent creating construct (usually `this`).
  - `id` — The construct's name.
  - `attrs` — A `DomainAttributes` object.

- `fromDomainEndpoint(scope: Construct, id: string, domainEndpoint: string): IDomain` (static) — Creates a domain construct that represents an external domain via domain endpoint.

  **Parameters**

  - `scope` — The parent creating construct (usually `this`).
  - `id` — The construct's name.
  - `domainEndpoint` — The domain's endpoint.

- `grantIndexRead(index: string, identity: IGrantable): Grant` — Grant read permissions for an index in this domain to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `index` — The index to grant permissions for.
  - `identity` — The principal.

- `grantIndexReadWrite(index: string, identity: IGrantable): Grant` — Grant read/write permissions for an index in this domain to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `index` — The index to grant permissions for.
  - `identity` — The principal.

- `grantIndexWrite(index: string, identity: IGrantable): Grant` — Grant write permissions for an index in this domain to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `index` — The index to grant permissions for.
  - `identity` — The principal.

- `grantPathRead(path: string, identity: IGrantable): Grant` — Grant read permissions for a specific path in this domain to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `path` — The path to grant permissions for.
  - `identity` — The principal.

- `grantPathReadWrite(path: string, identity: IGrantable): Grant` — Grant read/write permissions for a specific path in this domain to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `path` — The path to grant permissions for.
  - `identity` — The principal.

- `grantPathWrite(path: string, identity: IGrantable): Grant` — Grant write permissions for a specific path in this domain to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `path` — The path to grant permissions for.
  - `identity` — The principal.

- `grantRead(identity: IGrantable): Grant` — Grant read permissions for this domain and its contents to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `identity` — The principal.

- `grantReadWrite(identity: IGrantable): Grant` — Grant read/write permissions for this domain and its contents to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `identity` — The principal.

- `grantWrite(identity: IGrantable): Grant` — Grant write permissions for this domain and its contents to an IAM principal (Role/Group/User).

  [disable-awslint:no-grants]

  **Parameters**

  - `identity` — The principal.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this domain.

- `metricAutomatedSnapshotFailure(props?: MetricOptions): Metric` — Metric for automated snapshot failures.

- `metricClusterIndexWritesBlocked(props?: MetricOptions): Metric` — Metric for the cluster blocking index writes.

- `metricClusterStatusRed(props?: MetricOptions): Metric` — Metric for the time the cluster status is red.

- `metricClusterStatusYellow(props?: MetricOptions): Metric` — Metric for the time the cluster status is yellow.

- `metricCPUUtilization(props?: MetricOptions): Metric` — Metric for CPU utilization.

- `metricFreeStorageSpace(props?: MetricOptions): Metric` — Metric for the storage space of nodes in the cluster.

- `metricIndexingLatency(props?: MetricOptions): Metric` — Metric for indexing latency.

- `metricJVMMemoryPressure(props?: MetricOptions): Metric` — Metric for JVM memory pressure.

- `metricKMSKeyError(props?: MetricOptions): Metric` — Metric for KMS key errors.

- `metricKMSKeyInaccessible(props?: MetricOptions): Metric` — Metric for KMS key being inaccessible.

- `metricMasterCPUUtilization(props?: MetricOptions): Metric` — Metric for master CPU utilization.

- `metricMasterJVMMemoryPressure(props?: MetricOptions): Metric` — Metric for master JVM memory pressure.

- `metricNodes(props?: MetricOptions): Metric` — Metric for the number of nodes.

- `metricSearchableDocuments(props?: MetricOptions): Metric` — Metric for number of searchable documents.

- `metricSearchLatency(props?: MetricOptions): Metric` — Metric for search latency.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
