How to grant permissions to AWS user for Hartl's rails tutorial

前端 未结 4 1278
故里飘歌
故里飘歌 2020-12-29 17:30

I don\'t know how (or where also) to grant read and write permission to the user from AWS so users can post pictures on sample_app in production enviroment. This is final ta

4条回答
  •  猫巷女王i
    2020-12-29 17:48

    For others in future, this answer helped me a lot.

    Go on Heroku, on your application, go to settings, hit Reveal Config Vars.

    Click on on Edit on the right side and enter your secrets there:

    S3_BUCKET: name of your bucket goes here
    S3_ACCESS_KEY: xxxxx
    S3_SECRET_KEY: xxxx
    

    On config/initializers/carrierwave.rb or wherever you're entering your secrets should have:

    CarrierWave.configure do |config|
      config.root = Rails.root.join('tmp') # adding these...
      config.cache_dir = 'carrierwave' # ...two lines
    
      config.fog_credentials = {
        :provider               => 'AWS',                        # required
        :s3_access_key_id      => ENV['S3_ACCESS_KEY'],                        # required
        :s3_secret_access_key  => ENV['S3_SECRET_KEY'],                     # required
        :region                 => 'eu-west-1',                  # optional, defaults to 'us-east-1'
        :host                   => 's3.example.com',             # optional, defaults to nil
        :endpoint               => 'https://s3.example.com:8080' # optional, defaults to nil
      }
      config.fog_directory  = ENV['S3_Bucket']                             # required
      config.fog_public     = false                                   # optional, defaults to true
      config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
    end
    

提交回复
热议问题