Created
August 4, 2016 20:03
-
-
Save thinkerbot/280299fdab9866cf7e2a3d0448729a4b to your computer and use it in GitHub Desktop.
Sign requests to get access to a role-controlled AWS elasticsearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
require 'faraday_middleware' | |
require 'faraday_middleware/aws_signers_v4' | |
require 'pp' | |
conn = Faraday.new(url: 'http://ENDPOINT') do |faraday| | |
faraday.request :aws_signers_v4, | |
credentials: Aws::InstanceProfileCredentials.new.credentials, | |
service_name: 'es', | |
region: 'REGION' | |
faraday.response :json, :content_type => /\bjson\b/ | |
faraday.response :raise_error | |
faraday.adapter Faraday.default_adapter | |
end | |
res = conn.get '/' | |
pp res.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment