Skip to content

anonfriese/terraform-aws-es-cleanup

 
 

Repository files navigation

AWS Lambda Elasticsearch Index Cleanup

Overview

This AWS Lambda function allows you to delete the old Elasticsearch indexes using SigV4Auth authentication. You configure the AWS Elasticsearch Access Policy authorizing the Lambda Role or the AWS Account number instead of using the IP address whitelist.

Diagram

Terraform version

Module compatible with Terraform 0.12

Module Input Variables

Inputs

Name Description Type Default Required
delete_after Numbers of days to preserve string "15" no
es_endpoint string n/a yes
index Index/indices to process comma separated, with all every index will be processed except '.kibana' string ".*" no
index_format Combined with 'index' varible is used to evaluate the index age string "%Y.%m.%d" no
prefix string "" no
python_version string "3.6" no
schedule string "cron(0 3 * * ? *)" no
security_group_ids Addiational Security Ids To add. list(string) [] no
skip_index Index/indices to skip string ".kibana*" no
subnet_ids Subnet IDs you want to deploy the lambda in. Only fill this in if you want to deploy your Lambda function inside a VPC. list(string) [] no
suffix string "" no
tags Tags to apply map { "Name": "es-cleanup" } no

Example

terraform {
  required_version = ">= 0.12"
}

provider "aws" {
  region = "eu-west-1"
}


module "public_es_cleanup" {
  source       = "giuliocalzolari/es-cleanup/aws"
  version      = "1.13.0"
  prefix       = "public_es_"
  es_endpoint  = "test-es-XXXXXXX.eu-central-1.es.amazonaws.com"
  delete_after = 365
}


module "vpc_es_cleanup" {
  source             = "giuliocalzolari/es-cleanup/aws"
  version            = "1.13.0"
  prefix             = "vpc_es_"
  es_endpoint        = "vpc-gc-demo-vpc-gloo5rzcdhyiykwdlots2hdjla.eu-central-1.es.amazonaws.com"
  index              = "all"
  delete_after       = 30
  subnet_ids         = ["subnet-d8660da2"]
  security_group_ids = ["sg-02dd3aa6da1b5"]
}

Authors

Module is maintained by Giulio Calzolari with help from these awesome contributors.

License

terraform-aws-es-cleanup is licensed under the Apache Software License 2.0. Originally developed by Cloudreach adapted in this repo due to Terraform Registry Requirements