getletterpress / athens

Simple AWS Athena queries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: IncompleteSignatureException

merefield opened this issue · comments

Thanks for all the work here.

Getting an error when attempting to run a query. Almost certainly my bad, but any assistance very much appreciated!

Dependencies:

aws-sdk-core (3.121.2)
aws-sdk-athena (1.42.0)
athens (0.4.0)

I can't go higher on the aws sdk's due to platform dependencies.

Config in initializer:

  Athens.configure do |config|
    config.output_location = "s3://my-bucket/my-folder/athena/results/",
    config.aws_access_key      = s3_access_key_id,
    config.aws_secret_key      = s3_secret_access_key,
    #config.aws_profile         = 'myprofile'  # Optional - I have this commented out for time being
    config.aws_region          = s3_region,
    config.wait_polling_period = 0.25
    config.result_encryption   = nil
  end

Rails console responses:

[3] pry(main)> conn = Athens::Connection.new(database: 'addresses')
=> #<Athens::Connection:0x0000558021402378 @client=#<Aws::Athena::Client>, @database_name="addresses">
[4] pry(main)> query = conn.execute("SELECT * FROM addresses")
Aws::Athena::Errors::IncompleteSignatureException: '"rH------------------------D1"' not a valid key=value pair (missing equal-sign) in Authorization header: 'AWS4-HMAC-SHA256 Credential=["A-------------------Q", "rH--------------------D1", "eu-west-2", 0.25]/20220317/eu-west-2/athena/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target, Signature=f0--------------------------------------------8b'.
from /home/merefield/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/aws-sdk-core-3.121.2/lib/seahorse/client/plugins/raise_response_errors.rb:17:in `call'

FYI due to unrelated exports to S3 using these credentials, I know the keys are correct.

Oh, whoops, not set up a policy, closing for now!

This was solved, I had typos (commas!) in my configure block!

Should be:

  Athens.configure do |config|
    config.output_location = "s3://my-bucket/my-folder/athena/results/"
    config.aws_access_key      = s3_access_key_id
    config.aws_secret_key      = s3_secret_access_key
    #config.aws_profile         = 'myprofile'  # Optional - I have this commented out for time being
    config.aws_region          = s3_region
    config.wait_polling_period = 0.25
    config.result_encryption   = nil
  end

Doh!