An AWS lambda function that runs daily to delete indices in elastic search.
- Update the
endpoint
to the elasticsearch cluster endpoint - Update the
region
to the region that the elasticsearch cluster is in - Add any indices configuration
** prefixes e.g.
logstash-
** Days to keep
Build the lambda function code by running ./build
. This will bundle the required dependencies and
scripts into a distribution.
- Ensure that you are logged into AWS cli
- Create a role by following the steps in Create IAM role for lambda
- Note the ARN of the new role as it is used below
- Run the deploy the script
export FUNCTION_ROLE=XXXX; ./deploy.sh
Depending on your setup you will need to add permissions for the lambda function role to query/delete Elasticsearch indices. See AWS Elasticsearch documentation for more information.
Thanks to Cristian Uroz who wrote the original gist