ListElasticsearchIndiciesUsingAwsRole

nicolaw 24th May 2019 at 1:53pm
AWS TechnicalNotes
pip install awscurl
iam="$(curl -sSL "http://169.254.169.254/latest/meta-data/iam/security-credentials/$(curl -sSL http://169.254.169.254/latest/meta-data/iam/security-credentials/)")"
awscurl -X GET "${elasticsearch_endpoint_url}/_stats/" \
  --access_key "$(jq -r .AccessKeyId <<< "$iam")" \
  --secret_key "$(jq -r .SecretAccessKey <<< "$iam")" \
  --security_token "$(jq -r .Token <<< "$iam")" \
  --region "$(curl -sSL http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/[a-z]$//')" \
  --service es \
  | jq  -r '.indices|keys'