Skip to content

Instantly share code, notes, and snippets.

@rayway30419
Last active July 15, 2016 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayway30419/dd34a499ccabce6ebf0307d4776bf5a7 to your computer and use it in GitHub Desktop.
Save rayway30419/dd34a499ccabce6ebf0307d4776bf5a7 to your computer and use it in GitHub Desktop.
Dynamic configure AWS credentials on Rails (while you using IAM role for your instance)
# config/initializers/aws-sdk.rb
# configure your credential at ~/.aws/credential
# [kdan]
# aws_access_key_id=your_access_key_id
# aws_secret_access_key=your_secret_access_key
if File.exist? File.expand_path('~/.aws/credentials')
Aws.config.update(
credentials: Aws::SharedCredentials.new(profile_name: 'kdan'),
)
end
Aws.config.update(
region: 'us-east-1'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment