The CDK Construct Library for AWS::Elasticsearch
Project description
Amazon Elasticsearch Service Construct Library
---| Features | Stability |
|---|---|
| CFN Resources | |
| Higher level constructs for Domain |
CFN Resources: All classes with the
Cfnprefix in this module (CFN Resources) are always stable and safe to use.
Experimental: Higher level constructs in this module that are marked as experimental are under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
Create a development cluster by simply specifying the version:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_elasticsearch as es
dev_domain = es.Domain(self, "Domain",
version=es.ElasticsearchVersion.V7_1
)
Create a production grade cluster by also specifying things like capacity and az distribution
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
prod_domain = es.Domain(self, "Domain",
version=es.ElasticsearchVersion.V7_1,
capacity={
"master_nodes": 5,
"data_nodes": 20
},
ebs={
"volume_size": 20
},
zone_awareness={
"availability_zone_count": 3
},
logging={
"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.
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:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
domain_endpoint = "https://my-domain-jcjotrt6f7otem4sqcwbch3c4u.us-east-1.es.amazonaws.com"
domain = Domain.from_domain_endpoint(self, "ImportedDomain", domain_endpoint)
Permissions
IAM
Helper methods also exist for managing access to the domain.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
lambda_ = lambda_.Function(self, "Lambda")
# Grant write access to the app-search index
domain.grant_index_write("app-search", lambda_)
# Grant read access to the 'app-search/_search' path
domain.grant_path_read("app-search/_search", lambda_)
Encryption
The domain can also be created with encryption enabled:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
domain = es.Domain(self, "Domain",
version=es.ElasticsearchVersion.V7_4,
ebs={
"volume_size": 100,
"volume_type": EbsDeviceVolumeType.GENERAL_PURPOSE_SSD
},
node_to_node_encryption=True,
encryption_at_rest={
"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.
Metrics
Helper methods exist to access common domain metrics for example:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
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 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.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
domain = es.Domain(self, "Domain",
version=es.ElasticsearchVersion.V7_1,
enforce_https=True,
node_to_node_encryption=True,
encryption_at_rest={
"enabled": True
},
fine_grained_access_control={
"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.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
domain = es.Domain(self, "Domain",
version=es.ElasticsearchVersion.V7_1,
use_unsigned_basic_auth=True
)
master_user_password = domain.master_user_password
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aws-cdk.aws-elasticsearch-1.76.0.tar.gz.
File metadata
- Download URL: aws-cdk.aws-elasticsearch-1.76.0.tar.gz
- Upload date:
- Size: 106.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ca6ad4270fc73e57683c596edfbb9737c9f51b0d2eccfdc26636564345d53b8
|
|
| MD5 |
6730b4f032ee352544fb23560421782b
|
|
| BLAKE2b-256 |
784025ea474dee6f4e4cf27630b1d591c0e16b9dafb265fa2d3ecdbc40a01683
|
File details
Details for the file aws_cdk.aws_elasticsearch-1.76.0-py3-none-any.whl.
File metadata
- Download URL: aws_cdk.aws_elasticsearch-1.76.0-py3-none-any.whl
- Upload date:
- Size: 104.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d64d9291fb003b5b84b1ec3adad41fa027c4d209f5b406aff96c78b35e45128
|
|
| MD5 |
d5749ae5b88006ca449219d0e4800173
|
|
| BLAKE2b-256 |
c45c414b360a6e743440df7aff417d0a60b0f965aa86efe4251c64407906eb67
|