Python 2.7
lambda_function.lambda_handler
Example: Input event:
{
"source_host": "http://<your_elasticsearch_server:9200>/",
"source_index": "blog",
"scroll": "5m",
"scan_options": {
"size": 500
},
"s3_bucket": "myBucket",
"s3_prefix": "dumps"
}
source_host
: index to read documents from.source_index
: index to read documents from.scroll
: (Optional) keep the scroll open for another minute. default to5m
scan_options.size
: (Optional) you will get back a maximum of size * number_of_primary_shards documents in each batch. default to500
s3_bucket
: s3 bucket name.s3_prefix
: (optional) s3 object prefix.
Execution result sample:
{
"acknowledged": true
}
# 1. Clone this repository with lambda function name
git clone https://github.com/KunihikoKido/aws-lambda-es-dumpdata.git es-daumpdata
# 2. Create and Activate a virtualenv
cd es-daumpdata
virtualenv env
source env/bin/activate
# 3. Install Python modules for virtualenv
pip install -r requirements/local.txt
# 4. Install Python modules for lambda function
fab setup
fab invoke
fab invoke:custom-event.json
fab makezip
fab aws-updatecode
fab aws-getconfig
fab aws-invoke
fab -l
Methods and Resources:
POST /{indexname}/_dumpdata
Request mapping template:
{
"source_host": "http://<your_elasticsearch_server>/",
"source_index": "$input.params('indexname')",
"scroll": "5m",
"scan_options": {
"size": 500
},
"s3_bucket": "myBucket",
"s3_prefix": "dumps"
}
Example Request:
POST /blog/_dumpdata