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

[improvement] Pulling AWS credentials from ENV variables instead of hardcoding it in aws.yml file #38

Open
ghost opened this issue Apr 11, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 11, 2015

I changed my config/initializers/s3_multipart.rb to look like this:

S3Multipart.configure do |config|
config.bucket_name = ENV['AWS_S3_BUCKET'],
config.s3_access_key = ENV['AWS_ACCESS_KEY_ID'],
config.s3_secret_key = ENV['AWS_SECRET_ACCESS_KEY'],
config.revision = "0.0.10.6"
end

@SampsonCrowley
Copy link

I like to have a hardcode version for development, so I modified it to take both. This way you don't need to set env variables on local dev environment. Just make sure to add aws.yml to your .gitignore

if Rails.env == "development"
  AWS_Config = YAML.load_file("config/aws.yml")[Rails.env]

  S3Multipart.configure do |config|
    config.bucket_name   = AWS_Config['bucket']
    config.s3_access_key = AWS_Config['access_key_id']
    config.s3_secret_key = AWS_Config['secret_access_key']
    config.revision      = AWS_Config['revision']
  end
else
  S3Multipart.configure do |config|
    config.bucket_name = ENV['AWS_S3_BUCKET'],
    config.s3_access_key = ENV['AWS_ACCESS_KEY_ID'],
    config.s3_secret_key = ENV['AWS_SECRET_ACCESS_KEY'],
    config.revision = "0.0.10.6"
  end
end

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

No branches or pull requests

1 participant