Skip to content

Commit 27160c3

Browse files
authored
docs(opensearch): add example for token based import (#20915)
Documentation for changes made in PR #15219 - issue #15188 Normally one would not put the domain endpoint as a static value in a CF stack. A more realistic use case is to manage an opensearch domain from CF stack A and use it via CF stack B, C, D ... Stack A would export the domainEndpoint and also domainArn - the other stacks can then import those values and import the domain. This PR will add an example for the realistic scenario so people do not end up with errors like "Invalid URL" when a token endpoint is provided. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 9b1051f commit 27160c3

File tree

1 file changed

+16
-0
lines changed
  • packages/@aws-cdk/aws-opensearchservice

1 file changed

+16
-0
lines changed

packages/@aws-cdk/aws-opensearchservice/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const slr = new iam.CfnServiceLinkedRole(this, 'Service Linked Role', {
9797

9898
## Importing existing domains
9999

100+
### Using a known domain endpoint
101+
100102
To import an existing domain into your CDK application, use the `Domain.fromDomainEndpoint` factory method.
101103
This method accepts a domain endpoint of an already existing domain:
102104

@@ -105,6 +107,20 @@ const domainEndpoint = 'https://my-domain-jcjotrt6f7otem4sqcwbch3c4u.us-east-1.e
105107
const domain = opensearch.Domain.fromDomainEndpoint(this, 'ImportedDomain', domainEndpoint);
106108
```
107109

110+
### Using the output of another CloudFormation stack
111+
112+
To import an existing domain with the help of an exported value from another CloudFormation stack,
113+
use the `Domain.fromDomainAttributes` factory method. This will accept tokens.
114+
115+
```ts
116+
const domainArn = Fn.importValue(`another-cf-stack-export-domain-arn`);
117+
const domainEndpoint = Fn.importValue(`another-cf-stack-export-domain-endpoint`);
118+
const domain = Domain.fromDomainAttributes(this, 'ImportedDomain', {
119+
domainArn,
120+
domainEndpoint,
121+
});
122+
```
123+
108124
## Permissions
109125

110126
### IAM

0 commit comments

Comments
 (0)