Module: MovableInk::AWS::ApiGateway

Included in:
MovableInk::AWS
Defined in:
lib/movable_ink/aws/api_gateway.rb

Instance Method Summary collapse

Instance Method Details

#post_signed_gateway_request(gateway_url:, region:, body:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/movable_ink/aws/api_gateway.rb', line 8

def post_signed_gateway_request(gateway_url:, region:, body:)
  credentials = Aws::CredentialProviderChain.new.resolve.credentials

  signer = Aws::Sigv4::Signer.new({
    service: 'execute-api',
    region: region,
    credentials: credentials
  })

  signature = signer.sign_request({
    http_method: 'POST',
    url: gateway_url,
    body: body,
  })

  HTTParty.post(gateway_url, {
    headers: signature.headers,
    body: body,
  })
end