See: Description
Interface | Description |
---|---|
AdvancedSecurityOptions |
(experimental) Specifies options for fine-grained access control.
|
CapacityConfig |
(experimental) Configures the capacity of the cluster such as the instance type and the number of instances.
|
CfnDomain.AdvancedSecurityOptionsInputProperty | |
CfnDomain.CognitoOptionsProperty | |
CfnDomain.DomainEndpointOptionsProperty | |
CfnDomain.EBSOptionsProperty | |
CfnDomain.ElasticsearchClusterConfigProperty | |
CfnDomain.EncryptionAtRestOptionsProperty | |
CfnDomain.LogPublishingOptionProperty | |
CfnDomain.MasterUserOptionsProperty | |
CfnDomain.NodeToNodeEncryptionOptionsProperty | |
CfnDomain.SnapshotOptionsProperty | |
CfnDomain.VPCOptionsProperty | |
CfnDomain.ZoneAwarenessConfigProperty | |
CfnDomainProps |
Properties for defining a `AWS::Elasticsearch::Domain`.
|
CognitoOptions |
(experimental) Configures Amazon ES to use Amazon Cognito authentication for Kibana.
|
CustomEndpointOptions |
(experimental) Configures a custom domain endpoint for the ES domain.
|
DomainAttributes |
(experimental) Reference to an Elasticsearch domain.
|
DomainProps |
(experimental) Properties for an AWS Elasticsearch Domain.
|
EbsOptions |
(experimental) The configurations of Amazon Elastic Block Store (Amazon EBS) volumes that are attached to data nodes in the Amazon ES domain.
|
EncryptionAtRestOptions |
(experimental) Whether the domain should encrypt data at rest, and if so, the AWS Key Management Service (KMS) key to use.
|
IDomain |
(experimental) An interface that represents an Elasticsearch domain - either created with the CDK, or an existing one.
|
IDomain.Jsii$Default |
Internal default implementation for
IDomain . |
LoggingOptions |
(experimental) Configures log settings for the domain.
|
ZoneAwarenessConfig |
(experimental) Specifies zone awareness configuration options.
|
Enum | Description |
---|---|
TLSSecurityPolicy |
(experimental) The minimum TLS version required for traffic to the domain.
|
---
Features | Stability
-----------------------------------|----------------------------------------------------------------
CFN Resources |
Higher level constructs for Domain |
CFN Resources: All classes with the
Cfn
prefix in this module (CFN Resources) are always stable and safe to use.
Stable: Higher level constructs in this module that are marked stable will not undergo any breaking changes. They will strictly follow the Semantic Versioning model.
Create a development cluster by simply specifying the version:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 import software.amazon.awscdk.aws_elasticsearch; Domain devDomain = new Domain(this, "Domain", new DomainProps() .version(es.ElasticsearchVersion.getV7_1()));
To perform version upgrades without replacing the entire domain, specify the enableVersionUpgrade
property.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 import software.amazon.awscdk.aws_elasticsearch; Domain devDomain = new Domain(this, "Domain", new DomainProps() .version(es.ElasticsearchVersion.getV7_10()) .enableVersionUpgrade(true));
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 Object prodDomain = Domain.Builder.create(this, "Domain") .version(es.ElasticsearchVersion.getV7_1()) .capacity(Map.of( "masterNodes", 5, "dataNodes", 20)) .ebs(Map.of( "volumeSize", 20)) .zoneAwareness(Map.of( "availabilityZoneCount", 3)) .logging(Map.of( "slowSearchLogEnabled", true, "appLogEnabled", true, "slowIndexLogEnabled", true)) .build();
This creates an Elasticsearch cluster and automatically sets up log groups for logging the domain logs and slow search logs.
Some cluster configurations (e.g VPC access) require the existence of the AWSServiceRoleForAmazonElasticsearchService
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:
Before you can proceed, you must enable a service-linked role to give Amazon ES...
To resolve this, you need to create the SLR. We recommend using the AWS CLI:
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:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 CfnServiceLinkedRole slr = new CfnServiceLinkedRole(this, "ElasticSLR", new CfnServiceLinkedRoleProps() .awsServiceName("es.amazonaws.com"));
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 String domainEndpoint = "https://my-domain-jcjotrt6f7otem4sqcwbch3c4u.us-east-1.es.amazonaws.com"; Object domain = Domain.fromDomainEndpoint(this, "ImportedDomain", domainEndpoint);
Helper methods also exist for managing access to the domain.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Object lambda = Function.Builder.create(this, "Lambda").build(); // Grant write access to the app-search index domain.grantIndexWrite("app-search", lambda); // Grant read access to the 'app-search/_search' path domain.grantPathRead("app-search/_search", lambda);
The domain can also be created with encryption enabled:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Object domain = Domain.Builder.create(this, "Domain") .version(es.ElasticsearchVersion.getV7_4()) .ebs(Map.of( "volumeSize", 100, "volumeType", EbsDeviceVolumeType.getGENERAL_PURPOSE_SSD())) .nodeToNodeEncryption(true) .encryptionAtRest(Map.of( "enabled", true)) .build();
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.
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.
Visit VPC Support for Amazon Elasticsearch Service Domains for more details.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Object vpc = new Vpc(this, "Vpc"); Object domainProps = Map.of( "version", es.ElasticsearchVersion.getV7_1(), "removalPolicy", RemovalPolicy.getDESTROY(), "vpc", vpc, // must be enabled since our VPC contains multiple private subnets. "zoneAwareness", Map.of( "enabled", true), "capacity", Map.of( // must be an even number since the default az count is 2. "dataNodes", 2)); new Domain(this, "Domain", domainProps);
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.
Helper methods exist to access common domain metrics for example:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Object freeStorageSpace = domain.metricFreeStorageSpace(); Object masterSysMemoryUtilization = domain.metric("MasterSysMemoryUtilization");
This module is part of the AWS Cloud Development Kit project.
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 Object domain = Domain.Builder.create(this, "Domain") .version(es.ElasticsearchVersion.getV7_1()) .enforceHttps(true) .nodeToNodeEncryption(true) .encryptionAtRest(Map.of( "enabled", true)) .fineGrainedAccessControl(Map.of( "masterUserName", "master-user")) .build(); Object masterUserPassword = domain.getMasterUserPassword();
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 Object domain = Domain.Builder.create(this, "Domain") .version(es.ElasticsearchVersion.getV7_1()) .useUnsignedBasicAuth(true) .build(); Object masterUserPassword = domain.getMasterUserPassword();
Audit logs can be enabled for a domain, but only when fine grained access control is enabled.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Object domain = Domain.Builder.create(this, "Domain") .version(es.ElasticsearchVersion.getV7_1()) .enforceHttps(true) .nodeToNodeEncryption(true) .encryptionAtRest(Map.of( "enabled", true)) .fineGrainedAccessControl(Map.of( "masterUserName", "master-user")) .logging(Map.of( "auditLogEnabled", true, "slowSearchLogEnabled", true, "appLogEnabled", true, "slowIndexLogEnabled", true)) .build();
UltraWarm nodes can be enabled to provide a cost-effective way to store large amounts of read-only data.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Object domain = Domain.Builder.create(this, "Domain") .version(es.ElasticsearchVersion.getV7_10()) .capacity(Map.of( "masterNodes", 2, "warmNodes", 2, "warmInstanceType", "ultrawarm1.medium.elasticsearch")) .build();
Custom endpoints can be configured to reach the ES domain under a custom domain name.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 Domain.Builder.create(stack, "Domain") .version(ElasticsearchVersion.getV7_7()) .customEndpoint(Map.of( "domainName", "search.example.com")) .build();
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
Copyright © 2021. All rights reserved.