aws-cdk.aws-elasticsearch


Nameaws-cdk.aws-elasticsearch JSON
Version 1.203.0 PyPI version JSON
download
home_pagehttps://github.com/aws/aws-cdk
SummaryThe CDK Construct Library for AWS::Elasticsearch
upload_time2023-05-31 23:02:25
maintainer
docs_urlNone
authorAmazon Web Services
requires_python~=3.7
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Amazon OpenSearch Service Construct Library

<!--BEGIN STABILITY BANNER-->---


![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)

> This API may emit warnings. Backward compatibility is not guaranteed.

---
<!--END STABILITY BANNER-->

> Instead of this module, we recommend using the [@aws-cdk/aws-opensearchservice](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-opensearchservice-readme.html) module. See [Amazon OpenSearch Service FAQs](https://aws.amazon.com/opensearch-service/faqs/#Name_change) for details. See [Migrating to OpenSearch](#migrating-to-opensearch) for migration instructions.

## Quick start

Create a development cluster by simply specifying the version:

```python
dev_domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1
)
```

To perform version upgrades without replacing the entire domain, specify the `enableVersionUpgrade` property.

```python
dev_domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_10,
    enable_version_upgrade=True
)
```

Create a production grade cluster by also specifying things like capacity and az distribution

```python
prod_domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1,
    capacity=es.CapacityConfig(
        master_nodes=5,
        data_nodes=20
    ),
    ebs=es.EbsOptions(
        volume_size=20
    ),
    zone_awareness=es.ZoneAwarenessConfig(
        availability_zone_count=3
    ),
    logging=es.LoggingOptions(
        slow_search_log_enabled=True,
        app_log_enabled=True,
        slow_index_log_enabled=True
    )
)
```

This creates an Elasticsearch cluster and automatically sets up log groups for
logging the domain logs and slow search logs.

## A note about SLR

Some cluster configurations (e.g VPC access) require the existence of the [`AWSServiceRoleForAmazonElasticsearchService`](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/slr.html) service-linked role.

When performing such operations via the AWS Console, this SLR is created automatically when needed. However, this is not the behavior when using CloudFormation. If an SLR is needed, but doesn't exist, you will encounter a failure message simlar to:

```console
Before you can proceed, you must enable a service-linked role to give Amazon ES...
```

To resolve this, you need to [create](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#create-service-linked-role) the SLR. We recommend using the AWS CLI:

```console
aws iam create-service-linked-role --aws-service-name es.amazonaws.com
```

You can also create it using the CDK, **but note that only the first application deploying this will succeed**:

```python
slr = iam.CfnServiceLinkedRole(self, "ElasticSLR",
    aws_service_name="es.amazonaws.com"
)
```

## Importing existing domains

To import an existing domain into your CDK application, use the `Domain.fromDomainEndpoint` factory method.
This method accepts a domain endpoint of an already existing domain:

```python
domain_endpoint = "https://my-domain-jcjotrt6f7otem4sqcwbch3c4u.us-east-1.es.amazonaws.com"
domain = es.Domain.from_domain_endpoint(self, "ImportedDomain", domain_endpoint)
```

## Permissions

### IAM

Helper methods also exist for managing access to the domain.

```python
# fn: lambda.Function
# domain: es.Domain


# Grant write access to the app-search index
domain.grant_index_write("app-search", fn)

# Grant read access to the 'app-search/_search' path
domain.grant_path_read("app-search/_search", fn)
```

## Encryption

The domain can also be created with encryption enabled:

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_4,
    ebs=es.EbsOptions(
        volume_size=100,
        volume_type=ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD
    ),
    node_to_node_encryption=True,
    encryption_at_rest=es.EncryptionAtRestOptions(
        enabled=True
    )
)
```

This sets up the domain with node to node encryption and encryption at
rest. You can also choose to supply your own KMS key to use for encryption at
rest.

## VPC Support

Elasticsearch domains can be placed inside a VPC, providing a secure communication between Amazon ES and other services within the VPC without the need for an internet gateway, NAT device, or VPN connection.

> See [Launching your Amazon OpenSearch Service domains within a VPC](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/vpc.html) for more details.

```python
vpc = ec2.Vpc(self, "Vpc")
domain_props = es.DomainProps(
    version=es.ElasticsearchVersion.V7_1,
    removal_policy=RemovalPolicy.DESTROY,
    vpc=vpc,
    # must be enabled since our VPC contains multiple private subnets.
    zone_awareness=es.ZoneAwarenessConfig(
        enabled=True
    ),
    capacity=es.CapacityConfig(
        # must be an even number since the default az count is 2.
        data_nodes=2
    )
)
es.Domain(self, "Domain", domain_props)
```

In addition, you can use the `vpcSubnets` property to control which specific subnets will be used, and the `securityGroups` property to control
which security groups will be attached to the domain. By default, CDK will select all *private* subnets in the VPC, and create one dedicated security group.

## Metrics

Helper methods exist to access common domain metrics for example:

```python
# domain: es.Domain

free_storage_space = domain.metric_free_storage_space()
master_sys_memory_utilization = domain.metric("MasterSysMemoryUtilization")
```

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

## Fine grained access control

The domain can also be created with a master user configured. The password can
be supplied or dynamically created if not supplied.

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1,
    enforce_https=True,
    node_to_node_encryption=True,
    encryption_at_rest=es.EncryptionAtRestOptions(
        enabled=True
    ),
    fine_grained_access_control=es.AdvancedSecurityOptions(
        master_user_name="master-user"
    )
)

master_user_password = domain.master_user_password
```

## Using unsigned basic auth

For convenience, the domain can be configured to allow unsigned HTTP requests
that use basic auth. Unless the domain is configured to be part of a VPC this
means anyone can access the domain using the configured master username and
password.

To enable unsigned basic auth access the domain is configured with an access
policy that allows anyonmous requests, HTTPS required, node to node encryption,
encryption at rest and fine grained access control.

If the above settings are not set they will be configured as part of enabling
unsigned basic auth. If they are set with conflicting values, an error will be
thrown.

If no master user is configured a default master user is created with the
username `admin`.

If no password is configured a default master user password is created and
stored in the AWS Secrets Manager as secret. The secret has the prefix
`<domain id>MasterUser`.

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1,
    use_unsigned_basic_auth=True
)

master_user_password = domain.master_user_password
```

## Custom access policies

If the domain requires custom access control it can be configured either as a
constructor property, or later by means of a helper method.

For simple permissions the `accessPolicies` constructor may be sufficient:

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1,
    access_policies=[
        iam.PolicyStatement(
            actions=["es:*ESHttpPost", "es:ESHttpPut*"],
            effect=iam.Effect.ALLOW,
            principals=[iam.AccountPrincipal("123456789012")],
            resources=["*"]
        )
    ]
)
```

For more complex use-cases, for example, to set the domain up to receive data from a
[cross-account Kinesis Firehose](https://aws.amazon.com/premiumsupport/knowledge-center/kinesis-firehose-cross-account-streaming/) the `addAccessPolicies` helper method
allows for policies that include the explicit domain ARN.

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1
)

domain.add_access_policies(
    iam.PolicyStatement(
        actions=["es:ESHttpPost", "es:ESHttpPut"],
        effect=iam.Effect.ALLOW,
        principals=[iam.AccountPrincipal("123456789012")],
        resources=[domain.domain_arn, f"{domain.domainArn}/*"]
    ),
    iam.PolicyStatement(
        actions=["es:ESHttpGet"],
        effect=iam.Effect.ALLOW,
        principals=[iam.AccountPrincipal("123456789012")],
        resources=[f"{domain.domainArn}/_all/_settings", f"{domain.domainArn}/_cluster/stats", f"{domain.domainArn}/index-name*/_mapping/type-name", f"{domain.domainArn}/roletest*/_mapping/roletest", f"{domain.domainArn}/_nodes", f"{domain.domainArn}/_nodes/stats", f"{domain.domainArn}/_nodes/*/stats", f"{domain.domainArn}/_stats", f"{domain.domainArn}/index-name*/_stats", f"{domain.domainArn}/roletest*/_stat"
        ]
    ))
```

## Audit logs

Audit logs can be enabled for a domain, but only when fine-grained access control is enabled.

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_1,
    enforce_https=True,
    node_to_node_encryption=True,
    encryption_at_rest=es.EncryptionAtRestOptions(
        enabled=True
    ),
    fine_grained_access_control=es.AdvancedSecurityOptions(
        master_user_name="master-user"
    ),
    logging=es.LoggingOptions(
        audit_log_enabled=True,
        slow_search_log_enabled=True,
        app_log_enabled=True,
        slow_index_log_enabled=True
    )
)
```

## UltraWarm

UltraWarm nodes can be enabled to provide a cost-effective way to store large amounts of read-only data.

```python
domain = es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_10,
    capacity=es.CapacityConfig(
        master_nodes=2,
        warm_nodes=2,
        warm_instance_type="ultrawarm1.medium.elasticsearch"
    )
)
```

## Custom endpoint

Custom endpoints can be configured to reach the ES domain under a custom domain name.

```python
es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_7,
    custom_endpoint=es.CustomEndpointOptions(
        domain_name="search.example.com"
    )
)
```

It is also possible to specify a custom certificate instead of the auto-generated one.

Additionally, an automatic CNAME-Record is created if a hosted zone is provided for the custom endpoint

## Advanced options

[Advanced cluster settings](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html#createdomain-configure-advanced-options) can used to configure additional options.

```python
es.Domain(self, "Domain",
    version=es.ElasticsearchVersion.V7_7,
    advanced_options={
        "rest.action.multi.allow_explicit_index": "false",
        "indices.fielddata.cache.size": "25",
        "indices.query.bool.max_clause_count": "2048"
    }
)
```

## Migrating to OpenSearch

To migrate from this module (`@aws-cdk/aws-elasticsearch`) to the new `@aws-cdk/aws-opensearchservice` module, you must modify your CDK application to refer to the new module (including some associated changes) and then perform a CloudFormation resource deletion/import.

### Necessary CDK Modifications

Make the following modifications to your CDK application to migrate to the `@aws-cdk/aws-opensearchservice` module.

* Rewrite module imports to use `'@aws-cdk/aws-opensearchservice` to `'@aws-cdk/aws-elasticsearch`.
  For example:

  ```python
  import aws_cdk.aws_elasticsearch as es
  from aws_cdk.aws_elasticsearch import Domain
  ```

  ...becomes...

  ```python
  import aws_cdk.aws_opensearchservice as opensearch
  from aws_cdk.aws_opensearchservice import Domain
  ```
* Replace instances of `es.ElasticsearchVersion` with `opensearch.EngineVersion`.
  For example:

  ```python
  version = es.ElasticsearchVersion.V7_1
  ```

  ...becomes...

  ```python
  version = opensearch.EngineVersion.ELASTICSEARCH_7_1
  ```
* Replace the `cognitoKibanaAuth` property of `DomainProps` with `cognitoDashboardsAuth`.
  For example:

  ```python
  es.Domain(self, "Domain",
      cognito_kibana_auth=es.CognitoOptions(
          identity_pool_id="test-identity-pool-id",
          user_pool_id="test-user-pool-id",
          role=role
      ),
      version=elasticsearch_version
  )
  ```

  ...becomes...

  ```python
  opensearch.Domain(self, "Domain",
      cognito_dashboards_auth=opensearch.CognitoOptions(
          identity_pool_id="test-identity-pool-id",
          user_pool_id="test-user-pool-id",
          role=role
      ),
      version=open_search_version
  )
  ```
* Rewrite instance type suffixes from `.elasticsearch` to `.search`.
  For example:

  ```python
  es.Domain(self, "Domain",
      capacity=es.CapacityConfig(
          master_node_instance_type="r5.large.elasticsearch"
      ),
      version=elasticsearch_version
  )
  ```

  ...becomes...

  ```python
  opensearch.Domain(self, "Domain",
      capacity=opensearch.CapacityConfig(
          master_node_instance_type="r5.large.search"
      ),
      version=open_search_version
  )
  ```
* Any `CfnInclude`'d domains will need to be re-written in their original template in
  order to be successfully included as a `opensearch.CfnDomain`

### CloudFormation Migration

Follow these steps to migrate your application without data loss:

* Ensure that the [removal policy](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.RemovalPolicy.html) on your domains are set to `RemovalPolicy.RETAIN`. This is the default for the domain construct, so nothing is required unless you have specifically set the removal policy to some other value.
* Remove the domain resource from your CloudFormation stacks by manually modifying the synthesized templates used to create the CloudFormation stacks. This may also involve modifying or deleting dependent resources, such as the custom resources that CDK creates to manage the domain's access policy or any other resource you have connected to the domain. You will need to search for references to each domain's logical ID to determine which other resources refer to it and replace or delete those references. Do not remove resources that are dependencies of the domain or you will have to recreate or import them before importing the domain. After modification, deploy the stacks through the AWS Management Console or using the AWS CLI.
* Migrate your CDK application to use the new `@aws-cdk/aws-opensearchservice` module by applying the necessary modifications listed above. Synthesize your application and obtain the resulting stack templates.
* Copy just the definition of the domain from the "migrated" templates to the corresponding "stripped" templates that you deployed above. [Import](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html) the orphaned domains into your CloudFormation stacks using these templates.
* Synthesize and deploy your CDK application to reconfigure/recreate the modified dependent resources. The CloudFormation stacks should now contain the same resources as existed prior to migration.
* Proceed with development as normal!



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aws/aws-cdk",
    "name": "aws-cdk.aws-elasticsearch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Amazon Web Services",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/1c/36/a29d3a70819d9b486df6124e280fb08525828967d321c2515029ec66588e/aws-cdk.aws-elasticsearch-1.203.0.tar.gz",
    "platform": null,
    "description": "# Amazon OpenSearch Service Construct Library\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)\n\n> This API may emit warnings. Backward compatibility is not guaranteed.\n\n---\n<!--END STABILITY BANNER-->\n\n> Instead of this module, we recommend using the [@aws-cdk/aws-opensearchservice](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-opensearchservice-readme.html) module. See [Amazon OpenSearch Service FAQs](https://aws.amazon.com/opensearch-service/faqs/#Name_change) for details. See [Migrating to OpenSearch](#migrating-to-opensearch) for migration instructions.\n\n## Quick start\n\nCreate a development cluster by simply specifying the version:\n\n```python\ndev_domain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1\n)\n```\n\nTo perform version upgrades without replacing the entire domain, specify the `enableVersionUpgrade` property.\n\n```python\ndev_domain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_10,\n    enable_version_upgrade=True\n)\n```\n\nCreate a production grade cluster by also specifying things like capacity and az distribution\n\n```python\nprod_domain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1,\n    capacity=es.CapacityConfig(\n        master_nodes=5,\n        data_nodes=20\n    ),\n    ebs=es.EbsOptions(\n        volume_size=20\n    ),\n    zone_awareness=es.ZoneAwarenessConfig(\n        availability_zone_count=3\n    ),\n    logging=es.LoggingOptions(\n        slow_search_log_enabled=True,\n        app_log_enabled=True,\n        slow_index_log_enabled=True\n    )\n)\n```\n\nThis creates an Elasticsearch cluster and automatically sets up log groups for\nlogging the domain logs and slow search logs.\n\n## A note about SLR\n\nSome cluster configurations (e.g VPC access) require the existence of the [`AWSServiceRoleForAmazonElasticsearchService`](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/slr.html) service-linked role.\n\nWhen performing such operations via the AWS Console, this SLR is created automatically when needed. However, this is not the behavior when using CloudFormation. If an SLR is needed, but doesn't exist, you will encounter a failure message simlar to:\n\n```console\nBefore you can proceed, you must enable a service-linked role to give Amazon ES...\n```\n\nTo resolve this, you need to [create](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#create-service-linked-role) the SLR. We recommend using the AWS CLI:\n\n```console\naws iam create-service-linked-role --aws-service-name es.amazonaws.com\n```\n\nYou can also create it using the CDK, **but note that only the first application deploying this will succeed**:\n\n```python\nslr = iam.CfnServiceLinkedRole(self, \"ElasticSLR\",\n    aws_service_name=\"es.amazonaws.com\"\n)\n```\n\n## Importing existing domains\n\nTo import an existing domain into your CDK application, use the `Domain.fromDomainEndpoint` factory method.\nThis method accepts a domain endpoint of an already existing domain:\n\n```python\ndomain_endpoint = \"https://my-domain-jcjotrt6f7otem4sqcwbch3c4u.us-east-1.es.amazonaws.com\"\ndomain = es.Domain.from_domain_endpoint(self, \"ImportedDomain\", domain_endpoint)\n```\n\n## Permissions\n\n### IAM\n\nHelper methods also exist for managing access to the domain.\n\n```python\n# fn: lambda.Function\n# domain: es.Domain\n\n\n# Grant write access to the app-search index\ndomain.grant_index_write(\"app-search\", fn)\n\n# Grant read access to the 'app-search/_search' path\ndomain.grant_path_read(\"app-search/_search\", fn)\n```\n\n## Encryption\n\nThe domain can also be created with encryption enabled:\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_4,\n    ebs=es.EbsOptions(\n        volume_size=100,\n        volume_type=ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD\n    ),\n    node_to_node_encryption=True,\n    encryption_at_rest=es.EncryptionAtRestOptions(\n        enabled=True\n    )\n)\n```\n\nThis sets up the domain with node to node encryption and encryption at\nrest. You can also choose to supply your own KMS key to use for encryption at\nrest.\n\n## VPC Support\n\nElasticsearch domains can be placed inside a VPC, providing a secure communication between Amazon ES and other services within the VPC without the need for an internet gateway, NAT device, or VPN connection.\n\n> See [Launching your Amazon OpenSearch Service domains within a VPC](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/vpc.html) for more details.\n\n```python\nvpc = ec2.Vpc(self, \"Vpc\")\ndomain_props = es.DomainProps(\n    version=es.ElasticsearchVersion.V7_1,\n    removal_policy=RemovalPolicy.DESTROY,\n    vpc=vpc,\n    # must be enabled since our VPC contains multiple private subnets.\n    zone_awareness=es.ZoneAwarenessConfig(\n        enabled=True\n    ),\n    capacity=es.CapacityConfig(\n        # must be an even number since the default az count is 2.\n        data_nodes=2\n    )\n)\nes.Domain(self, \"Domain\", domain_props)\n```\n\nIn addition, you can use the `vpcSubnets` property to control which specific subnets will be used, and the `securityGroups` property to control\nwhich security groups will be attached to the domain. By default, CDK will select all *private* subnets in the VPC, and create one dedicated security group.\n\n## Metrics\n\nHelper methods exist to access common domain metrics for example:\n\n```python\n# domain: es.Domain\n\nfree_storage_space = domain.metric_free_storage_space()\nmaster_sys_memory_utilization = domain.metric(\"MasterSysMemoryUtilization\")\n```\n\nThis module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.\n\n## Fine grained access control\n\nThe domain can also be created with a master user configured. The password can\nbe supplied or dynamically created if not supplied.\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1,\n    enforce_https=True,\n    node_to_node_encryption=True,\n    encryption_at_rest=es.EncryptionAtRestOptions(\n        enabled=True\n    ),\n    fine_grained_access_control=es.AdvancedSecurityOptions(\n        master_user_name=\"master-user\"\n    )\n)\n\nmaster_user_password = domain.master_user_password\n```\n\n## Using unsigned basic auth\n\nFor convenience, the domain can be configured to allow unsigned HTTP requests\nthat use basic auth. Unless the domain is configured to be part of a VPC this\nmeans anyone can access the domain using the configured master username and\npassword.\n\nTo enable unsigned basic auth access the domain is configured with an access\npolicy that allows anyonmous requests, HTTPS required, node to node encryption,\nencryption at rest and fine grained access control.\n\nIf the above settings are not set they will be configured as part of enabling\nunsigned basic auth. If they are set with conflicting values, an error will be\nthrown.\n\nIf no master user is configured a default master user is created with the\nusername `admin`.\n\nIf no password is configured a default master user password is created and\nstored in the AWS Secrets Manager as secret. The secret has the prefix\n`<domain id>MasterUser`.\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1,\n    use_unsigned_basic_auth=True\n)\n\nmaster_user_password = domain.master_user_password\n```\n\n## Custom access policies\n\nIf the domain requires custom access control it can be configured either as a\nconstructor property, or later by means of a helper method.\n\nFor simple permissions the `accessPolicies` constructor may be sufficient:\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1,\n    access_policies=[\n        iam.PolicyStatement(\n            actions=[\"es:*ESHttpPost\", \"es:ESHttpPut*\"],\n            effect=iam.Effect.ALLOW,\n            principals=[iam.AccountPrincipal(\"123456789012\")],\n            resources=[\"*\"]\n        )\n    ]\n)\n```\n\nFor more complex use-cases, for example, to set the domain up to receive data from a\n[cross-account Kinesis Firehose](https://aws.amazon.com/premiumsupport/knowledge-center/kinesis-firehose-cross-account-streaming/) the `addAccessPolicies` helper method\nallows for policies that include the explicit domain ARN.\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1\n)\n\ndomain.add_access_policies(\n    iam.PolicyStatement(\n        actions=[\"es:ESHttpPost\", \"es:ESHttpPut\"],\n        effect=iam.Effect.ALLOW,\n        principals=[iam.AccountPrincipal(\"123456789012\")],\n        resources=[domain.domain_arn, f\"{domain.domainArn}/*\"]\n    ),\n    iam.PolicyStatement(\n        actions=[\"es:ESHttpGet\"],\n        effect=iam.Effect.ALLOW,\n        principals=[iam.AccountPrincipal(\"123456789012\")],\n        resources=[f\"{domain.domainArn}/_all/_settings\", f\"{domain.domainArn}/_cluster/stats\", f\"{domain.domainArn}/index-name*/_mapping/type-name\", f\"{domain.domainArn}/roletest*/_mapping/roletest\", f\"{domain.domainArn}/_nodes\", f\"{domain.domainArn}/_nodes/stats\", f\"{domain.domainArn}/_nodes/*/stats\", f\"{domain.domainArn}/_stats\", f\"{domain.domainArn}/index-name*/_stats\", f\"{domain.domainArn}/roletest*/_stat\"\n        ]\n    ))\n```\n\n## Audit logs\n\nAudit logs can be enabled for a domain, but only when fine-grained access control is enabled.\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_1,\n    enforce_https=True,\n    node_to_node_encryption=True,\n    encryption_at_rest=es.EncryptionAtRestOptions(\n        enabled=True\n    ),\n    fine_grained_access_control=es.AdvancedSecurityOptions(\n        master_user_name=\"master-user\"\n    ),\n    logging=es.LoggingOptions(\n        audit_log_enabled=True,\n        slow_search_log_enabled=True,\n        app_log_enabled=True,\n        slow_index_log_enabled=True\n    )\n)\n```\n\n## UltraWarm\n\nUltraWarm nodes can be enabled to provide a cost-effective way to store large amounts of read-only data.\n\n```python\ndomain = es.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_10,\n    capacity=es.CapacityConfig(\n        master_nodes=2,\n        warm_nodes=2,\n        warm_instance_type=\"ultrawarm1.medium.elasticsearch\"\n    )\n)\n```\n\n## Custom endpoint\n\nCustom endpoints can be configured to reach the ES domain under a custom domain name.\n\n```python\nes.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_7,\n    custom_endpoint=es.CustomEndpointOptions(\n        domain_name=\"search.example.com\"\n    )\n)\n```\n\nIt is also possible to specify a custom certificate instead of the auto-generated one.\n\nAdditionally, an automatic CNAME-Record is created if a hosted zone is provided for the custom endpoint\n\n## Advanced options\n\n[Advanced cluster settings](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html#createdomain-configure-advanced-options) can used to configure additional options.\n\n```python\nes.Domain(self, \"Domain\",\n    version=es.ElasticsearchVersion.V7_7,\n    advanced_options={\n        \"rest.action.multi.allow_explicit_index\": \"false\",\n        \"indices.fielddata.cache.size\": \"25\",\n        \"indices.query.bool.max_clause_count\": \"2048\"\n    }\n)\n```\n\n## Migrating to OpenSearch\n\nTo migrate from this module (`@aws-cdk/aws-elasticsearch`) to the new `@aws-cdk/aws-opensearchservice` module, you must modify your CDK application to refer to the new module (including some associated changes) and then perform a CloudFormation resource deletion/import.\n\n### Necessary CDK Modifications\n\nMake the following modifications to your CDK application to migrate to the `@aws-cdk/aws-opensearchservice` module.\n\n* Rewrite module imports to use `'@aws-cdk/aws-opensearchservice` to `'@aws-cdk/aws-elasticsearch`.\n  For example:\n\n  ```python\n  import aws_cdk.aws_elasticsearch as es\n  from aws_cdk.aws_elasticsearch import Domain\n  ```\n\n  ...becomes...\n\n  ```python\n  import aws_cdk.aws_opensearchservice as opensearch\n  from aws_cdk.aws_opensearchservice import Domain\n  ```\n* Replace instances of `es.ElasticsearchVersion` with `opensearch.EngineVersion`.\n  For example:\n\n  ```python\n  version = es.ElasticsearchVersion.V7_1\n  ```\n\n  ...becomes...\n\n  ```python\n  version = opensearch.EngineVersion.ELASTICSEARCH_7_1\n  ```\n* Replace the `cognitoKibanaAuth` property of `DomainProps` with `cognitoDashboardsAuth`.\n  For example:\n\n  ```python\n  es.Domain(self, \"Domain\",\n      cognito_kibana_auth=es.CognitoOptions(\n          identity_pool_id=\"test-identity-pool-id\",\n          user_pool_id=\"test-user-pool-id\",\n          role=role\n      ),\n      version=elasticsearch_version\n  )\n  ```\n\n  ...becomes...\n\n  ```python\n  opensearch.Domain(self, \"Domain\",\n      cognito_dashboards_auth=opensearch.CognitoOptions(\n          identity_pool_id=\"test-identity-pool-id\",\n          user_pool_id=\"test-user-pool-id\",\n          role=role\n      ),\n      version=open_search_version\n  )\n  ```\n* Rewrite instance type suffixes from `.elasticsearch` to `.search`.\n  For example:\n\n  ```python\n  es.Domain(self, \"Domain\",\n      capacity=es.CapacityConfig(\n          master_node_instance_type=\"r5.large.elasticsearch\"\n      ),\n      version=elasticsearch_version\n  )\n  ```\n\n  ...becomes...\n\n  ```python\n  opensearch.Domain(self, \"Domain\",\n      capacity=opensearch.CapacityConfig(\n          master_node_instance_type=\"r5.large.search\"\n      ),\n      version=open_search_version\n  )\n  ```\n* Any `CfnInclude`'d domains will need to be re-written in their original template in\n  order to be successfully included as a `opensearch.CfnDomain`\n\n### CloudFormation Migration\n\nFollow these steps to migrate your application without data loss:\n\n* Ensure that the [removal policy](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.RemovalPolicy.html) on your domains are set to `RemovalPolicy.RETAIN`. This is the default for the domain construct, so nothing is required unless you have specifically set the removal policy to some other value.\n* Remove the domain resource from your CloudFormation stacks by manually modifying the synthesized templates used to create the CloudFormation stacks. This may also involve modifying or deleting dependent resources, such as the custom resources that CDK creates to manage the domain's access policy or any other resource you have connected to the domain. You will need to search for references to each domain's logical ID to determine which other resources refer to it and replace or delete those references. Do not remove resources that are dependencies of the domain or you will have to recreate or import them before importing the domain. After modification, deploy the stacks through the AWS Management Console or using the AWS CLI.\n* Migrate your CDK application to use the new `@aws-cdk/aws-opensearchservice` module by applying the necessary modifications listed above. Synthesize your application and obtain the resulting stack templates.\n* Copy just the definition of the domain from the \"migrated\" templates to the corresponding \"stripped\" templates that you deployed above. [Import](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html) the orphaned domains into your CloudFormation stacks using these templates.\n* Synthesize and deploy your CDK application to reconfigure/recreate the modified dependent resources. The CloudFormation stacks should now contain the same resources as existed prior to migration.\n* Proceed with development as normal!\n\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "The CDK Construct Library for AWS::Elasticsearch",
    "version": "1.203.0",
    "project_urls": {
        "Homepage": "https://github.com/aws/aws-cdk",
        "Source": "https://github.com/aws/aws-cdk.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbac2ec9f2fc0cb5fe1a216ac80e50a3598d161107b907d5ab0e4ad1f4b7716e",
                "md5": "2c1bd2f4a05e9132a8099943454eebfb",
                "sha256": "ed47a944c07ae6ce63a61fdbafe9d7691b6f8a05e5343f581f78ad7a5b4a94aa"
            },
            "downloads": -1,
            "filename": "aws_cdk.aws_elasticsearch-1.203.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2c1bd2f4a05e9132a8099943454eebfb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.7",
            "size": 206999,
            "upload_time": "2023-05-31T22:54:55",
            "upload_time_iso_8601": "2023-05-31T22:54:55.129116Z",
            "url": "https://files.pythonhosted.org/packages/cb/ac/2ec9f2fc0cb5fe1a216ac80e50a3598d161107b907d5ab0e4ad1f4b7716e/aws_cdk.aws_elasticsearch-1.203.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c36a29d3a70819d9b486df6124e280fb08525828967d321c2515029ec66588e",
                "md5": "09111eedacafb1e4cc8db3dd5901d160",
                "sha256": "62825573af4f3f967240270baa2216ae7b26538f56560da18771f2fc7e3f026d"
            },
            "downloads": -1,
            "filename": "aws-cdk.aws-elasticsearch-1.203.0.tar.gz",
            "has_sig": false,
            "md5_digest": "09111eedacafb1e4cc8db3dd5901d160",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.7",
            "size": 207152,
            "upload_time": "2023-05-31T23:02:25",
            "upload_time_iso_8601": "2023-05-31T23:02:25.603464Z",
            "url": "https://files.pythonhosted.org/packages/1c/36/a29d3a70819d9b486df6124e280fb08525828967d321c2515029ec66588e/aws-cdk.aws-elasticsearch-1.203.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-31 23:02:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aws",
    "github_project": "aws-cdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aws-cdk.aws-elasticsearch"
}
        
Elapsed time: 0.10546s