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 2 commits
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', {
});
```

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

```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
17 changes: 17 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,16 @@ 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
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-upgradeelasticsearchdomain
* @default - false
*/
readonly enableVersionUpgrade?: boolean;

}

/**
Expand Down Expand Up @@ -1541,6 +1551,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
15 changes: 15 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,19 @@ 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', {
UpdatePolicy: {
EnableVersionUpgrade: true,
},
}, ResourcePart.CompleteDefinition);
});

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

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