Skip to content

davidh83110/lambda-elasticsearch-index-rotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lambda-elasticsearch-index-rotation

Automatically delete older indics on AWS Elasticsearch.

Environment

  • Python 3
  • Lambda function and execution role
  • Make sure the Lambda role has been added in AWS Elasticsearch's allow list on the access policy
  • Cloudwatch Event Rule

Build

$ pip install -r requirements.txt -t ./
$ zip -r artifact.zip ./*

Parameters (Configure on Cloudwatch Event)

  • endpoint (string)
    • The endpoint of AWS Elasticsearch with "https://" and without "/" on the suffix.
  • region (string)
    • The region of AWS Elasticsearch.
  • older_than (int)
    • The rotation days of index.
  • exclude (list)
    • The keyword contains in index names which will not be deleted.

Example

{
    "endpoint":"https://search-test-es-wrr22fsafafwe2.ap-northeast-1.es.amazonaws.com", 
    "region": "ap-northeast-1", 
    "older_than": "1",
    "exclude": ["testapi", "testaudit"]
},
{
    "endpoint":"https://searchwewqewqewqewqewqefwe2.ap-northeast-1.es.amazonaws.com", 
    "region": "us-west-1", 
    "older_than": "1",
    "exclude": [""]
}

TODO

  • Terraform

Releases

No releases published

Packages

No packages published

Languages