Skip to content
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ direnv edit
aws es describe-elasticsearch-domain --domain-name ${ALIS_APP_ID}api | jq '.DomainStatus.Endpoint'
```

Enable logs in Production.

```bash
./enable_elasticsearch_logs.sh YOUR_DOMAIN_NAME
```

And add ElasticSearch Endpoint to SSM.
- See: https://github.com/AlisProject/environment

Expand Down
36 changes: 23 additions & 13 deletions elasticsearch-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,29 @@ Parameters:
Resources:
ElasticSearchService:
Type: "AWS::Elasticsearch::Domain"
Properties:
AccessPolicies: !Join
- ''
- - '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "'
- !Ref ApiLambdaRole
- '" }, "Action": "es:*", "Resource": "'
- 'arn:aws:es:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':domain/'
- !Ref "AWS::StackName"
- '/*" } ] }'
Properties:
AccessPolicies:
!Sub
- |-
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "${ApiLambdaRole}"
},
"Action": "es:*",
"Resource": "arn:aws:es:${Region}:${AccountId}:domain/${StackName}/*"
}
]
}
- {
ApiLambdaRole: !Ref ApiLambdaRole,
Region: !Ref 'AWS::Region',
AccountId: !Ref 'AWS::AccountId',
StackName: !Ref 'AWS::StackName'
}
AdvancedOptions:
rest.action.multi.allow_explicit_index: 'true'
DomainName: !Ref "AWS::StackName"
Expand Down
8 changes: 8 additions & 0 deletions enable_elasticsearch_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

aws es describe-elasticsearch-domain --domain-name ${1} | jq '.DomainStatus.Endpoint'
aws es update-elasticsearch-domain-config --domain-name ${1} --log-publishing-options \
"SEARCH_SLOW_LOGS={CloudWatchLogsLogGroupArn=arn:aws:logs:ap-northeast-1:090169530579:log-group:/aws/aes/search-slow-logs:*,Enabled=true}"


# ,INDEX_SLOW_LOGS={CloudWatchLogsLogGroupArn=arn:aws:logs:us-east-1:123456789012:log-group:my-other-log-group,Enabled=true}