DEV Community

Zaw Htut Win
Zaw Htut Win

Posted on

This Gem is on 🔥🔥 (for AWS signature v4)

If you follow the AWS documentation for signature v4 signing process, you know it requires you to going through alot of steps. 😨

Finally I found faraday_middleware-aws-sigv4 gem.

For me it's a live-saver. 💖

conn = Faraday.new(url: API_BASE_URL) do |faraday|
    faraday.request :aws_signers_v4,
         credentials: Aws::Credentials.new(response["access_key_id"], response["secret_key"], response["session_token"]),
          service_name: 'execute-api',
          region: 'us-east-1'
  faraday.adapter Faraday.default_adapter
end
puts conn.headers
response = conn.post('/orders') do |req|
    req.headers['Content-Type'] = 'application/json'
end
puts response.body
Enter fullscreen mode Exit fullscreen mode

Discussion (0)