Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(elasticsearch): Support EnableVersionUpgrade update policy #12239

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ const devDomain = new es.Domain(this, 'Domain', {
});
```

Allowing upgrading an Amazon ES domain to a new version of Elasticsearch rather than replacing the entire domain resource.
hassanazharkhan marked this conversation as resolved.
Show resolved Hide resolved

```ts
import * as es from '@aws-cdk/aws-elasticsearch';

const devDomain = new es.Domain(this, 'Domain', {
version: es.ElasticsearchVersion.V7_9,
enableVersionUpgrade: true // defaults to false
});
```

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

```ts
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-elasticsearch/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,15 @@ export interface DomainProps {
* @default - false
*/
readonly useUnsignedBasicAuth?: boolean;

/**
* To upgrade an Amazon ES domain to a new version of Elasticsearch rather than replacing the entire
* domain resource, use the EnableVersionUpgrade update policy.
*
hassanazharkhan marked this conversation as resolved.
Show resolved Hide resolved
* @default - false
*/
readonly enableVersionUpgrade?: boolean;

}

/**
Expand Down Expand Up @@ -1541,6 +1550,13 @@ export class Domain extends DomainBase implements IDomain {
: undefined,
});

if (props.enableVersionUpgrade) {
this.domain.cfnOptions.updatePolicy = {
...this.domain.cfnOptions.updatePolicy,
enableVersionUpgrade: props.enableVersionUpgrade,
};
}

if (logGroupResourcePolicy) { this.domain.node.addDependency(logGroupResourcePolicy); }

if (props.domainName) { this.node.addMetadata('aws:cdk:hasPhysicalName', props.domainName); }
Expand Down
56 changes: 56 additions & 0 deletions packages/@aws-cdk/aws-elasticsearch/test/domain.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable jest/expect-expect */
hassanazharkhan marked this conversation as resolved.
Show resolved Hide resolved
import '@aws-cdk/assert/jest';
import { ResourcePart } from '@aws-cdk/assert';
import { Metric, Statistic } from '@aws-cdk/aws-cloudwatch';
import { Subnet, Vpc, EbsDeviceVolumeType } from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
Expand Down Expand Up @@ -67,6 +69,60 @@ test('minimal example renders correctly', () => {
});
});

test('minimal example with resource props renders correctly', () => {
iliapolo marked this conversation as resolved.
Show resolved Hide resolved
new Domain(stack, 'Domain', {
version: ElasticsearchVersion.V7_1,
enableVersionUpgrade: true,
});

expect(stack).toHaveResource('AWS::Elasticsearch::Domain', {
Properties: {
CognitoOptions: {
Enabled: false,
},
DomainEndpointOptions: {
EnforceHTTPS: false,
TLSSecurityPolicy: 'Policy-Min-TLS-1-0-2019-07',
},
EBSOptions: {
EBSEnabled: true,
VolumeSize: 10,
VolumeType: 'gp2',
},
ElasticsearchClusterConfig: {
DedicatedMasterEnabled: false,
InstanceCount: 1,
InstanceType: 'r5.large.elasticsearch',
ZoneAwarenessEnabled: false,
},
ElasticsearchVersion: '7.1',
EncryptionAtRestOptions: {
Enabled: false,
},
LogPublishingOptions: {
AUDIT_LOGS: {
Enabled: false,
},
ES_APPLICATION_LOGS: {
Enabled: false,
},
SEARCH_SLOW_LOGS: {
Enabled: false,
},
INDEX_SLOW_LOGS: {
Enabled: false,
},
},
NodeToNodeEncryptionOptions: {
Enabled: false,
},
},
hassanazharkhan marked this conversation as resolved.
Show resolved Hide resolved
UpdatePolicy: {
EnableVersionUpgrade: true,
},
}, ResourcePart.CompleteDefinition);
});

describe('log groups', () => {

test('slowSearchLogEnabled should create a custom log group', () => {
Expand Down