Here are some handy jq
scripts that I've found useful.
Since the AWS CLI outputs JSON this is a natural fit. Sometimes the built-in --query
doesn't quite go far enough.
Examples:
aws lambda list-event-source-mappings | jq -c '.EventSourceMappings[] | { uuid: .UUID, arn: .EventSourceArn, state: .State }'
This command transforms a search result blob into a list of JSON objects suitable for input into ES's "bulk" command.
curl localhost:9200/_search?size=200 | \
jq -c '.hits.hits[] | { index: { _id: ._id, _index: ._index, _type: ._type } },._source' \
> bulk.txt
So, for a simple, no-frills replication strategy from localhost:9200 to localhost:9201, consider this pipeline:
curl localhost:9200/_search?size=200 | \
jq -c '.hits.hits[] | { index: { _id: ._id, _index: ._index, _type: ._type } },._source' | \
curl -s -H "Content-Type: application/x-ndjson" -X POST localhost:9201/_bulk --data-binary @-; echo