Search code examples
aws-cloudformationaws-elasticsearchamazon-elasticsearch

How can I add retention policy to AWS ElasticSearch created from CloudFormation?


I am sending logs from different environments to AWS ElasticSearch using fluentd. The AWS ES is created using a CloudFormation stack. How can do following two things:

  1. Add a retention policy to keep all logs for 30 days.
  2. Add retention policy as per environemts, say, env x for 60 days and env y for 7 days.

I could not find anything in CloudFormation stack to add retention policy.


Solution

  • There is no such feature in Cloudformation so far. What can be done is to use Lambda with schedule to apply these retention rules. The aws documentation contains an example using lambda and the curator library.