Skip to content

Instantly share code, notes, and snippets.

@ryo0301
Last active August 29, 2015 14:09
Show Gist options
  • Save ryo0301/071a49e7645afcbeadf6 to your computer and use it in GitHub Desktop.
Save ryo0301/071a49e7645afcbeadf6 to your computer and use it in GitHub Desktop.
aws-sdk-coreでcredentialsのプロファイルを切り替える ref: http://qiita.com/ryo0301/items/39308a5dc457b5df59ee
[default]
aws_access_key_id = DEFAULT_ACCESS_KEY_ID
aws_secret_access_key = DEFAULT_SECRET_ACCESS_KEY
aws_session_token = DEFAULT_SESSION_TOKEN
[dev]
aws_access_key_id = DEV_ACCESS_KEY_ID
aws_secret_access_key = DEV_SECRET_ACCESS_KEY
require 'aws-sdk-core'
ec2 = Aws::EC2::Client.new region: 'ap-northeast-1', profile: 'dev'
require 'aws-sdk-core'
creds = Aws::SharedCredentials.new path: '/path/to/creds', profile_name: 'dev'
ec2 = Aws::EC2::Client.new region: 'ap-northeast-1', credentials: creds
require 'aws-sdk-core'
Aws.config[:profile] = 'dev'
Aws.config[:region] = 'ap-northeast-1'
ec2 = Aws::EC2::Client.new
require 'aws-sdk-core'
creds = Aws::SharedCredentials.new path: '/path/to/creds', profile_name: 'dev'
Aws.config[:credentials] = creds
Aws.config[:region] = 'ap-northeast-1'
ec2 = Aws::EC2::Client.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment