Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { StackProps } from 'aws-cdk-lib';
import { App, RemovalPolicy, Stack } from 'aws-cdk-lib';
import type { Construct } from 'constructs';
import * as opensearch from 'aws-cdk-lib/aws-opensearchservice';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';

class TestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

new opensearch.Domain(this, 'Domain', {
version: opensearch.EngineVersion.OPENSEARCH_2_17,
removalPolicy: RemovalPolicy.DESTROY,
enableAutoSoftwareUpdate: true,
useLatestServiceSoftwareForBlueGreen: true,
capacity: {
multiAzWithStandbyEnabled: false,
},
});
}
}

const app = new App();
const stack = new TestStack(app, 'cdk-integ-opensearch-software-update-options');

new IntegTest(app, 'OpenSearchSoftwareUpdateOptionsInteg', {
testCases: [stack],
});
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-opensearchservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ The domain can be configured to use service software updates.
const domain = new Domain(this, 'Domain', {
version: EngineVersion.OPENSEARCH_1_3,
enableAutoSoftwareUpdate: true,
useLatestServiceSoftwareForBlueGreen: true,
});
```

Expand Down
14 changes: 13 additions & 1 deletion packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,17 @@ export interface DomainProps {
*/
readonly enableAutoSoftwareUpdate?: boolean;

/**
* Specifies whether the domain should use the latest service software version during a blue/green deployment.
* If enabled, the domain will automatically use the latest available service software when a blue/green
* deployment is triggered.
*
* @see https://docs.aws.amazon.com/opensearch-service/latest/developerguide/service-software.html
*
* @default - false
*/
readonly useLatestServiceSoftwareForBlueGreen?: boolean;

/**
* Specify either dual stack or IPv4 as your IP address type.
* Dual stack allows you to share domain resources across IPv4 and IPv6 address types, and is the recommended option.
Expand Down Expand Up @@ -2124,8 +2135,9 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
},
},
} : undefined,
softwareUpdateOptions: props.enableAutoSoftwareUpdate !== undefined ? {
softwareUpdateOptions: (props.enableAutoSoftwareUpdate !== undefined || props.useLatestServiceSoftwareForBlueGreen !== undefined) ? {
autoSoftwareUpdateEnabled: props.enableAutoSoftwareUpdate,
useLatestServiceSoftwareForBlueGreen: props.useLatestServiceSoftwareForBlueGreen,
} : undefined,
ipAddressType: props.ipAddressType,
aimlOptions: props.s3VectorsEngineEnabled !== undefined ? {
Expand Down
41 changes: 41 additions & 0 deletions packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,47 @@ each(testedOpenSearchVersions).describe('offPeakWindow and softwareUpdateOptions
});
});

test('with useLatestServiceSoftwareForBlueGreen', () => {
new Domain(stack, 'Domain', {
version: engineVersion,
useLatestServiceSoftwareForBlueGreen: true,
});

Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', {
SoftwareUpdateOptions: {
UseLatestServiceSoftwareForBlueGreen: true,
},
});
});

test('with useLatestServiceSoftwareForBlueGreen set to false', () => {
new Domain(stack, 'Domain', {
version: engineVersion,
useLatestServiceSoftwareForBlueGreen: false,
});

Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', {
SoftwareUpdateOptions: {
UseLatestServiceSoftwareForBlueGreen: false,
},
});
});

test('with both enableAutoSoftwareUpdate and useLatestServiceSoftwareForBlueGreen', () => {
new Domain(stack, 'Domain', {
version: engineVersion,
enableAutoSoftwareUpdate: true,
useLatestServiceSoftwareForBlueGreen: true,
});

Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', {
SoftwareUpdateOptions: {
AutoSoftwareUpdateEnabled: true,
UseLatestServiceSoftwareForBlueGreen: true,
},
});
});

test('with invalid offPeakWindowStart', () => {
expect(() => {
new Domain(stack, 'Domain1', {
Expand Down
Loading