Skip to content

Commit d3e9f3e

Browse files
authored
chore(elasticsearch): Explain SLR requirement in README (#13546)
Explain when an SLR is needed, and how to create one. This can be a source of confusion because the ES console experience hides the SLR from users by automatically creating it if needed. Related to #13367 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3e1148e commit d3e9f3e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ const prodDomain = new es.Domain(this, 'Domain', {
7474
This creates an Elasticsearch cluster and automatically sets up log groups for
7575
logging the domain logs and slow search logs.
7676

77+
## A note about SLR
78+
79+
Some cluster configurations (e.g VPC access) require the existence of the [`AWSServiceRoleForAmazonElasticsearchService`](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/slr-es.html) Service-Linked Role.
80+
81+
When performing such operations via the AWS Console, this SLR is created automatically when needed. However, this is not the behavior when using CloudFormation. If an SLR is needed, but doesn't exist, you will encounter a failure message simlar to:
82+
83+
```console
84+
Before you can proceed, you must enable a service-linked role to give Amazon ES...
85+
```
86+
87+
To resolve this, you need to [create](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#create-service-linked-role) the SLR. We recommend using the AWS CLI:
88+
89+
```console
90+
aws iam create-service-linked-role --aws-service-name es.amazonaws.com
91+
```
92+
93+
You can also create it using the CDK, **but note that only the first application deploying this will succeed**:
94+
95+
```ts
96+
const slr = new iam.CfnServiceLinkedRole(this, 'ElasticSLR', {
97+
awsServiceName: 'es.amazonaws.com'
98+
});
99+
```
100+
77101
## Importing existing domains
78102

79103
To import an existing domain into your CDK application, use the `Domain.fromDomainEndpoint` factory method.

0 commit comments

Comments
 (0)