# Domain

Provides an Elasticsearch domain.

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

- CloudFormation: [`AWS::Elasticsearch::Domain`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-elasticsearch-domain.html)
- L1 type: [`CfnDomain`](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.CfnDomain.html)
- Source: [`aws-elasticsearch/lib/domain.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-elasticsearch/lib/domain.ts#L1377)
- Type last changed: v2.236.0 · 23 Jan 2026

## Example

```ts
const domain = new es.Domain(this, 'Domain', {
  version: es.ElasticsearchVersion.V7_4,
  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)[] — use opensearchservice module instead

  **Default:** No access policies.

- `advancedOptions`: { [key: string]: string } — use opensearchservice module instead

  **Default:** no advanced options are specified

- `automatedSnapshotStartHour`: number — use opensearchservice module instead

  **Default:** Hourly automated snapshots not used

  Only applies for Elasticsearch
  versions below 5.3.

- `capacity`: [CapacityConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.CapacityConfig.html) — use opensearchservice module instead

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

- `cognitoKibanaAuth`: [CognitoOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.CognitoOptions.html) — use opensearchservice module instead

  **Default:** Cognito not used for authentication to Kibana.

- `customEndpoint`: [CustomEndpointOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.CustomEndpointOptions.html) — use opensearchservice module instead

  **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 — use opensearchservice module instead

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

- `ebs`: [EbsOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.EbsOptions.html) — use opensearchservice module instead

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

  For more information, see
  [Configuring EBS-based Storage]
  (https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createupdatedomains.html#es-createdomain-configure-ebs)
  in the Amazon Elasticsearch Service Developer Guide.

- `enableVersionUpgrade`: boolean = false — use opensearchservice module instead

- `encryptionAtRest`: [EncryptionAtRestOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.EncryptionAtRestOptions.html) — use opensearchservice module instead

  **Default:** No encryption at rest

- `enforceHttps`: boolean = false — use opensearchservice module instead

- `fineGrainedAccessControl`: [AdvancedSecurityOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.AdvancedSecurityOptions.html) — use opensearchservice module instead

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

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

- `logging`: [LoggingOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.LoggingOptions.html) — use opensearchservice module instead

  **Default:** No logs are published

- `nodeToNodeEncryption`: boolean — use opensearchservice module instead

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

  Requires Elasticsearch version 6.0 or later.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.RETAIN — use opensearchservice module instead

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — use opensearchservice module instead

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

  Only used if `vpc` is specified.

- `tlsSecurityPolicy`: [TLSSecurityPolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.TLSSecurityPolicy.html) = TLSSecurityPolicy.TLS_1_0 — use opensearchservice module instead

- `useUnsignedBasicAuth`: boolean = false — use opensearchservice module instead

  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`: [ElasticsearchVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticsearch.ElasticsearchVersion.html) (required) — use opensearchservice module instead

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) — use opensearchservice module instead

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

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html)[] — use opensearchservice module instead

  **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_elasticsearch.ZoneAwarenessConfig.html) — use opensearchservice module instead

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

## Properties

- `appLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — use opensearchservice module instead

- `auditLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — use opensearchservice module instead

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — use opensearchservice module instead

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

- `domainArn`: string — Arn of the Elasticsearch domain.

- `domainEndpoint`: string — use opensearchservice module instead

- `domainName`: string — Domain name of the Elasticsearch domain.

- `domainRef`: [DomainReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_elasticsearch.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_elasticsearch.DomainGrants.html) — Collection of grant methods for a Domain.

- `masterUserPassword`: [SecretValue](/cdk/api/v2/docs/aws-cdk-lib.SecretValue.html) — use opensearchservice module instead

- `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) — use opensearchservice module instead

- `slowSearchLogGroup`: [ILogGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogGroup.html) — use opensearchservice module instead

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

## Methods

- `addAccessPolicies(...accessPolicyStatements: PolicyStatement[]): void` — use opensearchservice module instead

- `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) — use opensearchservice module instead

  **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) — use opensearchservice module instead

  **Parameters**

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

- `grantIndexRead(index: string, identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

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

- `grantIndexReadWrite(index: string, identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

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

- `grantIndexWrite(index: string, identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

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

- `grantPathRead(path: string, identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

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

- `grantPathReadWrite(path: string, identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

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

- `grantPathWrite(path: string, identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

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

- `grantRead(identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

  - `identity` — The principal.

- `grantReadWrite(identity: IGrantable): Grant` — use opensearchservice module instead

  [disable-awslint:no-grants]

  **Parameters**

  - `identity` — The principal.

- `grantWrite(identity: IGrantable): Grant` — use opensearchservice module instead

  [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` — use opensearchservice module instead

- `metricAutomatedSnapshotFailure(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricClusterIndexWritesBlocked(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricClusterStatusRed(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricClusterStatusYellow(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricCPUUtilization(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricFreeStorageSpace(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricIndexingLatency(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricJVMMemoryPressure(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricKMSKeyError(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricKMSKeyInaccessible(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricMasterCPUUtilization(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricMasterJVMMemoryPressure(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricNodes(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricSearchableDocuments(props?: MetricOptions): Metric` — use opensearchservice module instead

- `metricSearchLatency(props?: MetricOptions): Metric` — use opensearchservice module instead

- `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.
