Commit a38b6ab6 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'aws-version-bump' into 'master'

Update aws-sdk-* gems to v3 and use faraday_middleware-aws-sigv4 gem

Closes #37931

See merge request gitlab-org/gitlab!22865
parents f44feb3a 39302c58
......@@ -132,8 +132,9 @@ gem 'seed-fu', '~> 2.3.7'
gem 'elasticsearch-model', '~> 6.1'
gem 'elasticsearch-rails', '~> 6.1', require: 'elasticsearch/rails/instrumentation'
gem 'elasticsearch-api', '~> 6.8'
gem 'aws-sdk'
gem 'faraday_middleware-aws-signers-v4'
gem 'aws-sdk-core', '~> 3'
gem 'aws-sdk-cloudformation', '~> 1'
gem 'faraday_middleware-aws-sigv4'
# Markdown and HTML processing
gem 'html-pipeline', '~> 2.12'
......
......@@ -81,13 +81,15 @@ GEM
attr_required (1.0.1)
awesome_print (1.8.0)
aws-eventstream (1.0.3)
aws-sdk (2.11.374)
aws-sdk-resources (= 2.11.374)
aws-sdk-core (2.11.374)
aws-sigv4 (~> 1.0)
aws-partitions (1.263.0)
aws-sdk-cloudformation (1.29.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sdk-core (3.88.0)
aws-eventstream (~> 1.0, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-resources (2.11.374)
aws-sdk-core (= 2.11.374)
aws-sigv4 (1.1.0)
aws-eventstream (~> 1.0, >= 1.0.2)
axiom-types (0.1.1)
......@@ -276,9 +278,9 @@ GEM
faraday (~> 0.8)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
faraday_middleware-aws-signers-v4 (0.1.7)
aws-sdk-resources (~> 2)
faraday (~> 0.9)
faraday_middleware-aws-sigv4 (0.3.0)
aws-sigv4 (~> 1.0)
faraday (>= 0.15)
faraday_middleware-multi_json (0.0.6)
faraday_middleware
multi_json
......@@ -1141,7 +1143,8 @@ DEPENDENCIES
atlassian-jwt (~> 0.2.0)
attr_encrypted (~> 3.1.0)
awesome_print
aws-sdk
aws-sdk-cloudformation (~> 1)
aws-sdk-core (~> 3)
babosa (~> 1.0.2)
base32 (~> 0.3.0)
batch-loader (~> 1.4.0)
......@@ -1187,7 +1190,7 @@ DEPENDENCIES
escape_utils (~> 1.1)
factory_bot_rails (~> 5.1.0)
faraday (~> 0.12)
faraday_middleware-aws-signers-v4
faraday_middleware-aws-sigv4
fast_blank
ffaker (~> 2.10)
flipper (~> 0.17.1)
......
# frozen_string_literal: true
require 'faraday_middleware/aws_sigv4'
module Gitlab
module Elastic
module Client
......@@ -17,7 +19,7 @@ module Gitlab
region = config[:aws_region]
::Elasticsearch::Client.new(base_config) do |fmid|
fmid.request(:aws_signers_v4, credentials: creds, service_name: 'es', region: region)
fmid.request(:aws_sigv4, credentials: creds, service: 'es', region: region)
end
else
::Elasticsearch::Client.new(base_config)
......
......@@ -28,6 +28,8 @@ describe Gitlab::Elastic::Client do
.to_return(status: 200, body: "RoleName", headers: {})
stub_request(:get, "http://169.254.169.254/latest/meta-data/iam/security-credentials/RoleName")
.to_return(status: 200, body: creds_response, headers: {})
stub_request(:put, "http://169.254.169.254/latest/api/token")
.to_return(status: 200, body: "", headers: {})
end
describe '.build' do
......@@ -62,8 +64,13 @@ describe Gitlab::Elastic::Client do
stub_request(:get, 'http://example-elastic:9200/foo/_all/1')
.with(
headers: {
'Authorization' => 'AWS4-HMAC-SHA256 Credential=0/20170303/us-east-1/es/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=4ba2aae19a476152dacf5a2191da67b0cf81b9d7152dab5c42b1bba701da19f1',
'Accept' => '*/*',
'Accept-Encoding' => 'gzip,deflate',
'Authorization' => 'AWS4-HMAC-SHA256 Credential=0/20170303/us-east-1/es/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date, Signature=e52132ac542972698e99d9a8337b7493e4ca6210f61fc8da5cbb8008d8b2fb87',
'Content-Type' => 'application/json',
'Date' => 'Fri, 03 Mar 2017 13:39:52 GMT',
'Host' => 'example-elastic:9200',
'User-Agent' => 'Faraday v0.15.4',
'X-Amz-Content-Sha256' => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
'X-Amz-Date' => '20170303T133952Z'
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment