Skip to content

Commit

Permalink
feat(opensearch): rebrand Elasticsearch as OpenSearch
Browse files Browse the repository at this point in the history
Amazon Elasticsearch Service is being rebranded to Amazon OpenSearch Service. All customer-facing references to Elasticsearch within AWS CDK must be replaced with their OpenSearch equivalent, including documentation and API. To avoid breaking existing customers, all API changes will be implemented as a deprecation of the old API and introduction of a new, rebranded API.

Concretely, this change consists of the following:

- add a disclaimer at the top of the @aws-cdk/aws-elasticsearch module README about the rebranding
- add migration instructions to the @aws-cdk/aws-elasticsearch module README
- introduce the @aws-cdk/aws-opensearch module
  - copy all files from the Elasticsearch module
  - uses new AWS::OpenSearch::Domain resource. CFN guarantees a no-replacement update when a resource moves from AWS::Elasticsearch::Domain to AWS::OpenSearch::Domain, meaning customers should be able to move from the old CDK module to the new one with no downtime.
  - rename DomainProps.cognitoKibanaAuth -> DomainProps.cognitoDashboardsAuth
  - replaces ElasticsearchVersion with OpenSearchVersion
    - ElasticsearchVersion.V{major}_{minor} -> OpenSearchVersion.ELASTICSEARCH_{major}_{minor}
    - ElasticsearchVersion.of(version: string) -> OpenSearchVersion.elasticsearch(version: string)
    - introduces OpenSearchVersion.OPENSEARCH_1_0 and OpenSearchVersion.openSearch(version: string)
  - replace .elasticsearch instance suffix with .search
  - rename logical ID and type of a custom resource (Custom::ElasticsearchAccessPolicy -> Custom::OpenSearchAccessPolicy) that we generate to update the domain's access policy. This will cause a resource replacement, which will avoid a CloudFormation error (Update of resource type is not permitted) for stacks that switch modules

Closes #16467
  • Loading branch information
BenChaimberg committed Sep 16, 2021
1 parent ae09c16 commit e6c4ca5
Show file tree
Hide file tree
Showing 42 changed files with 11,429 additions and 21 deletions.
102 changes: 102 additions & 0 deletions packages/@aws-cdk/aws-elasticsearch/README.md
Expand Up @@ -22,6 +22,8 @@ Higher level constructs for Domain | ![Stable](https://img.shields.io/badge/stab

<!--END STABILITY BANNER-->

> Amazon Elasticsearch Service has been renamed to Amazon OpenSearch Service; consequently, the [@aws-cdk/aws-opensearchservice](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-opensearchservice-readme.html) module should be used instead. See [Amazon OpenSearch Service FAQs](https://aws.amazon.com/opensearch-service/faqs/#Name_change) for details. See [Migrating to OpenSearch](#migrating-to-opensearch) for migration instructions.
## Quick start

Create a development cluster by simply specifying the version:
Expand Down Expand Up @@ -305,3 +307,103 @@ new Domain(stack, 'Domain', {
},
});
```

## Migrating to OpenSearch

To migrate from this module (`@aws-cdk/aws-elasticsearch`) to the new `@aws-cdk/aws-opensearchservice` module, you must modify your CDK application to refer to the new module (including some associated changes) and then perform a CloudFormation resource deletion/import.

### Necessary CDK Modifications

Make the following modifications to your CDK application to migrate to the `@aws-cdk/aws-opensearchservice` module.

- Rewrite module imports to use `'@aws-cdk/aws-opensearchservice` to `'@aws-cdk/aws-elasticsearch`.
For example:

```ts nofixture
import * as es from '@aws-cdk/aws-elasticsearch';
import { Domain } from '@aws-cdk/aws-elasticsearch';
```

...becomes...

```ts nofixture
import * as opensearch from '@aws-cdk/aws-opensearchservice';
import { Domain } from '@aws-cdk/aws-opensearchservice';
```

- Replace instances of `es.ElasticsearchVersion` with `opensearch.EngineVersion`.
For example:

```ts fixture=migrate-opensearch
const version = es.ElasticsearchVersion.V7_1;
```

...becomes...

```ts fixture=migrate-opensearch
const version = opensearch.EngineVersion.ELASTICSEARCH_7_1;
```

- Replace the `cognitoKibanaAuth` property of `DomainProps` with `cognitoDashboardsAuth`.
For example:

```ts fixture=migrate-opensearch
new es.Domain(this, 'Domain', {
cognitoKibanaAuth: {
identityPoolId: 'test-identity-pool-id',
userPoolId: 'test-user-pool-id',
role: role,
},
version: elasticsearchVersion,
});
```

...becomes...

```ts fixture=migrate-opensearch
new opensearch.Domain(this, 'Domain', {
cognitoDashboardsAuth: {
identityPoolId: 'test-identity-pool-id',
userPoolId: 'test-user-pool-id',
role: role,
},
version: openSearchVersion,
});
```

- Rewrite instance type suffixes from `.elasticsearch` to `.search`.
For example:

```ts fixture=migrate-opensearch
new es.Domain(this, 'Domain', {
capacity: {
masterNodeInstanceType: 'r5.large.elasticsearch',
},
version: elasticsearchVersion,
});
```

...becomes...

```ts fixture=migrate-opensearch
new opensearch.Domain(this, 'Domain', {
capacity: {
masterNodeInstanceType: 'r5.large.search',
},
version: openSearchVersion,
});
```

- Any `CfnInclude`'d domains will need to be re-written in their original template in
order to be successfully included as a `opensearch.CfnDomain`

### CloudFormation Migration

Follow these steps to migrate your application without data loss:

- Ensure that the [removal policy](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.RemovalPolicy.html) on your domains are set to `RemovalPolicy.RETAIN`. This is the default for the domain construct, so nothing is required unless you have specifically set the removal policy to some other value.
- Remove the domain resource from your CloudFormation stacks by manually modifying the synthesized templates used to create the CloudFormation stacks. This may also involve modifying or deleting dependent resources, such as the custom resources that CDK creates to manage the domain's access policy or any other resource you have connected to the domain. You will need to search for references to each domain's logical ID to determine which other resources refer to it and replace or delete those references. Do not remove resources that are dependencies of the domain or you will have to recreate or import them before importing the domain. After modification, deploy the stacks through the AWS Management Console or using the AWS CLI.
- Migrate your CDK application to use the new `@aws-cdk/aws-opensearchservice` module by applying the necessary modifications listed above. Synthesize your application and obtain the resulting stack templates.
- Copy just the definition of the domain from the "migrated" templates to the corresponding "stripped" templates that you deployed above. [Import](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html) the orphaned domains into your CloudFormation stacks using these templates.
- Synthesize and deploy your CDK application to reconfigure/recreate the modified dependent resources. The CloudFormation stacks should now contain the same resources as existed prior to migration.
- Proceed with development as normal!
@@ -0,0 +1,16 @@
import * as cdk from '@aws-cdk/core';
import * as es from '@aws-cdk/aws-elasticsearch';
import * as iam from '@aws-cdk/aws-iam';
import * as opensearch from '@aws-cdk/aws-opensearchservice';

declare const role: iam.IRole;
declare const elasticsearchVersion: es.ElasticsearchVersion;
declare const openSearchVersion: opensearch.EngineVersion;

class Fixture extends cdk.Construct {
constructor(scope: cdk.Construct, id: string) {
super(scope, id);

/// here
}
}
Expand Up @@ -244,7 +244,15 @@
{
"Ref": "Domain66AC69E0"
},
"\",\"AccessPolicies\":\"{\\\"Statement\\\":[{\\\"Action\\\":\\\"es:ESHttp*\\\",\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"AWS\\\":\\\"*\\\"},\\\"Resource\\\":\\\"*\\\"}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"outputPath\":\"DomainConfig.ElasticsearchClusterConfig.AccessPolicies\",\"physicalResourceId\":{\"id\":\"",
"\",\"AccessPolicies\":\"{\\\"Statement\\\":[{\\\"Action\\\":\\\"es:ESHttp*\\\",\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"AWS\\\":\\\"arn:",
{
"Ref": "AWS::Partition"
},
":iam::",
{
"Ref": "AWS::AccountId"
},
":root\\\"},\\\"Resource\\\":\\\"*\\\"}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"outputPath\":\"DomainConfig.ElasticsearchClusterConfig.AccessPolicies\",\"physicalResourceId\":{\"id\":\"",
{
"Ref": "Domain66AC69E0"
},
Expand All @@ -260,7 +268,15 @@
{
"Ref": "Domain66AC69E0"
},
"\",\"AccessPolicies\":\"{\\\"Statement\\\":[{\\\"Action\\\":\\\"es:ESHttp*\\\",\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"AWS\\\":\\\"*\\\"},\\\"Resource\\\":\\\"*\\\"}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"outputPath\":\"DomainConfig.ElasticsearchClusterConfig.AccessPolicies\",\"physicalResourceId\":{\"id\":\"",
"\",\"AccessPolicies\":\"{\\\"Statement\\\":[{\\\"Action\\\":\\\"es:ESHttp*\\\",\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"AWS\\\":\\\"arn:",
{
"Ref": "AWS::Partition"
},
":iam::",
{
"Ref": "AWS::AccountId"
},
":root\\\"},\\\"Resource\\\":\\\"*\\\"}],\\\"Version\\\":\\\"2012-10-17\\\"}\"},\"outputPath\":\"DomainConfig.ElasticsearchClusterConfig.AccessPolicies\",\"physicalResourceId\":{\"id\":\"",
{
"Ref": "Domain66AC69E0"
},
Expand Down Expand Up @@ -343,7 +359,7 @@
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9"
"Ref": "AssetParametersf4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924S3BucketA716C641"
},
"S3Key": {
"Fn::Join": [
Expand All @@ -356,7 +372,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B"
"Ref": "AssetParametersf4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924S3VersionKey2B40A946"
}
]
}
Expand All @@ -369,7 +385,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B"
"Ref": "AssetParametersf4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924S3VersionKey2B40A946"
}
]
}
Expand All @@ -396,17 +412,17 @@
}
},
"Parameters": {
"AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": {
"AssetParametersf4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924S3BucketA716C641": {
"Type": "String",
"Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\""
"Description": "S3 bucket for asset \"f4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924\""
},
"AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": {
"AssetParametersf4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924S3VersionKey2B40A946": {
"Type": "String",
"Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\""
"Description": "S3 key for asset version \"f4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924\""
},
"AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": {
"AssetParametersf4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924ArtifactHash2B031F57": {
"Type": "String",
"Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\""
"Description": "Artifact hash for asset \"f4b39c228007db80daf4497318957f3b455415dce70fdbb7aeb6151a0b6da924\""
}
}
}
Expand Up @@ -33,7 +33,7 @@ class TestStack extends Stack {
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['es:ESHttp*'],
principals: [new iam.AnyPrincipal()],
principals: [new iam.AccountRootPrincipal()],
resources: ['*'],
}),
],
Expand Down
Expand Up @@ -296,7 +296,7 @@
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3BucketB17E5ABD"
"Ref": "AssetParametersf2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3ddS3Bucket292EB571"
},
"S3Key": {
"Fn::Join": [
Expand All @@ -309,7 +309,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3VersionKey77778F6A"
"Ref": "AssetParametersf2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3ddS3VersionKeyCE9A5F79"
}
]
}
Expand All @@ -322,7 +322,7 @@
"Fn::Split": [
"||",
{
"Ref": "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3VersionKey77778F6A"
"Ref": "AssetParametersf2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3ddS3VersionKeyCE9A5F79"
}
]
}
Expand Down Expand Up @@ -608,17 +608,17 @@
}
},
"Parameters": {
"AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3BucketB17E5ABD": {
"AssetParametersf2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3ddS3Bucket292EB571": {
"Type": "String",
"Description": "S3 bucket for asset \"5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4\""
"Description": "S3 bucket for asset \"f2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3dd\""
},
"AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3VersionKey77778F6A": {
"AssetParametersf2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3ddS3VersionKeyCE9A5F79": {
"Type": "String",
"Description": "S3 key for asset version \"5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4\""
"Description": "S3 key for asset version \"f2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3dd\""
},
"AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4ArtifactHash580E429C": {
"AssetParametersf2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3ddArtifactHash86854188": {
"Type": "String",
"Description": "Artifact hash for asset \"5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4\""
"Description": "Artifact hash for asset \"f2b7671fc0b80f63e3c94441727cbff799bb0f4991339d990d7b4c419e1ab3dd\""
}
}
}
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-opensearchservice/.eslintrc.js
@@ -0,0 +1,3 @@
const baseConfig = require('cdk-build-tools/config/eslintrc');
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
module.exports = baseConfig;
19 changes: 19 additions & 0 deletions packages/@aws-cdk/aws-opensearchservice/.gitignore
@@ -0,0 +1,19 @@
*.js
*.js.map
*.d.ts
tsconfig.json
node_modules
*.generated.ts
dist
.jsii

.LAST_BUILD
.nyc_output
coverage
.nycrc
.LAST_PACKAGE
*.snk
nyc.config.js
!.eslintrc.js
!jest.config.js
junit.xml
29 changes: 29 additions & 0 deletions packages/@aws-cdk/aws-opensearchservice/.npmignore
@@ -0,0 +1,29 @@
# Don't include original .ts files when doing `npm pack`
*.ts
!*.d.ts
coverage
.nyc_output
*.tgz

dist
.LAST_PACKAGE
.LAST_BUILD
!*.js

# Include .jsii
!.jsii

*.snk

*.tsbuildinfo

tsconfig.json

.eslintrc.js
jest.config.js

# exclude cdk artifacts
**/cdk.out
junit.xml
test/
!*.lit.ts

0 comments on commit e6c4ca5

Please sign in to comment.