10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

aws-cliの設定ファイルをruby aws-sdkから使う

10
Last updated at Posted at 2014-09-01

AWSコマンドラインインタフェースaccess_key_idsecret_access_key を設定すると ~/.aws/config というファイルが生成される。

AWS SDK for Ruby からこれを使って認証を行うには SharedCredentialFileProvider を使う。このファイルには region についての情報も含まれるが、渡されないので改めて明示的に書く必要があるので注意。

require 'aws-sdk'

path = File.expand_path('~/.aws/config')
provider = AWS::Core::CredentialProviders::SharedCredentialFileProvider.new(path: path)
AWS.config(credential_provider: provider, region: 'ap-northeast-1')
10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?