Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use aws sdk v2 #85

Merged
merged 24 commits into from Sep 10, 2015
Merged

Use aws sdk v2 #85

merged 24 commits into from Sep 10, 2015

Conversation

okkez
Copy link
Contributor

@okkez okkez commented Jul 10, 2015

I'm trying to use aws-sdk v2.

TODOs

  • Fix unit test
  • Test in real world

See also #69 .

@okkez okkez changed the title WIP: Use aws sdk v2 Use aws sdk v2 Jul 23, 2015

config = CONFIG_TIME_SLICE + 'auto_create_bucket true'
d = create_time_sliced_driver(config)
assert_nothing_raised { d.run }
end

def test_aws_credential_provider_default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these tests are intented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

See okkez@05bf971

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@repeatedly
Copy link
Member

@ijin Could you also check this PR?

@repeatedly
Copy link
Member

Sorry, could you rebase the commits?
After that, I will announce this PR for finding testers.

okkez and others added 15 commits August 11, 2015 21:57
AWS -> Aws
Because aws-adk does not have such option.
This is for backward compatibility.

If users use fluent-plugin-s3 0.59 or older with default
configuration, aws-sdk v1 set "us-east-1" to S3 region automatically.
But aws-sdk v2 does not set default value to S3 region, and raise
error.

See also: https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
Because `Aws::Plugins::S3Md5s::Handler#md5` reads `Tempfile` object.
Because aws-sdk-core calculate md5 digest from tempfile.
This change suppresses following warning:

    [warn]: fluent/output.rb:354:rescue in try_flush: temporarily
    failed to flush the buffer. next_retry=2015-07-23 11:25:46 +0900
    error_class="Aws::S3::Errors::BadDigest" error="The Content-MD5
    you specified did not match what we received."
    plugin_id="object:1e1e370"
This change follows c6e5665.
The following locations will be searched in order for credentials:

* :access_key_id, :secret_access_key, and :session_token options
* ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
* HOME/.aws/credentials shared credentials file
* EC2 instance profile credentials See Plugins::RequestSigner for more details.

See also:
http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#initialize-instance_method
aws-sdk v2 does not have API to set credential providers.
It is calculated by aws-sdk automatically.
Because flexmock have not been maintained for several years.
@okkez
Copy link
Contributor Author

okkez commented Aug 11, 2015

Rebased!

config_param :use_server_side_encryption, :string, :default => nil
config_param :aws_key_id, :string, :default => nil, :secret => true
config_param :aws_sec_key, :string, :default => nil, :secret => true
config_param :aws_iam_retries, :integer, :default => 5
config_param :s3_bucket, :string
config_param :s3_region, :string, :default => nil
config_param :s3_region, :string, :default => "us-east-1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should keep with nil. Otherwise, ENV['AWS_REGION'] won't be effective.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When keep nil, it breaks backward compatibility.
See 4db98de.

Which is preferred?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then, how about :default => ENV['AWS_REGION'] || 'us-east-1'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented e59099f.

@ijin
Copy link
Member

ijin commented Aug 16, 2015

This might break backwards compatibility for some users. A few are attributable to v2 simply not supporting them, but some are from code changes.

I do like the idea of replacing flex-mock with rr, though.

okkez and others added 3 commits August 20, 2015 16:31
* Aws::AssumeRoleCredentials
* Aws::InstanceProfileCrecentials
* Aws::SharedCredentials

I cannot set some options via `config_param`,
so comment out them, for now.
credentials_options[:duration_seconds] = c.duration_seconds if c.duration_seconds
credentials_options[:external_id] = c.external_id if c.external_id
options[:credentials] = Aws::AssumeRoleCredentials.new(credentials_options)
when @instance_profile_credentials
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using same credentials if user specifies "aws_iam_retries" for backward compatibility?

when @instance_profile_credentials
#...
when @aws_iam_retries
$log.warn "'aws_iam_retries' parameter is deprecated. Use 'instance_profile_credentials' instead"
credentials_options[:retries] = @aws_iam_retries
options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!
I've changed.

This reverts commit 7f783ac.

For backward compatibility.
But `aws_iam_retries` is deprecated configuration.
This change is only for backward compatibility.
@repeatedly
Copy link
Member

Thanks for applying review!

@ijin How about recent changes? I want to merge this PR and release v0.6.0-pre1 for testing.

repeatedly added a commit that referenced this pull request Sep 10, 2015
@repeatedly repeatedly merged commit cc3a175 into fluent:master Sep 10, 2015
@ijin
Copy link
Member

ijin commented Sep 11, 2015

LGTM.

@okkez Does the required minimum IAM policy change at all?

@okkez
Copy link
Contributor Author

okkez commented Sep 11, 2015

@ijin I'm not sure about IAM policy.
I have not considered required minimum IAM policy.

@okkez okkez mentioned this pull request Oct 1, 2015
@okkez okkez deleted the use-aws-sdk-v2 branch January 25, 2016 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants