前提・実現したいこと
プログラミング初心者です。
Cloud9環境で、ruby on rails を使ったアプリケーション制作をしています。
carrierwaveを使ったherokuでの画像アップロードのストレージとしてS3を使いたいと考えています。
発生している問題・エラーメッセージ
本番環境でエラーが出ているので何度かアクセスキーの変更などを行うも一向に解決しなかったので開発環境からもS3を使って画像アップロードをするように試してみたところ、開発環境でも同様のエラーメッセージが発生しました。
「ArgumentError: Missing required arguments: aws_secret_access_key」
gemはfog-awsを使っています。
ネットの情報をいろいろ調べてみて実践しているのですが、一向に解決しなかったのでこちらに投稿させていただきました。
些細なことでもよいので、ご教示いただければと思います。
エラーメッセージ
/home/ec2-user/environment/original_app_2/config/initializers/carrierwave.rb:10: warning: key :aws_access_key_id is duplicated and overwritten on line 11 [fog][WARNING] Unable to fetch credentials: Expected(200) <=> Actual(404 Not Found) rails aborted! ArgumentError: Missing required arguments: aws_secret_access_key /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/fog-core-2.1.2/lib/fog/core/service.rb:244:in `validate_options' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/fog-core-2.1.2/lib/fog/core/service.rb:268:in `handle_settings' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/fog-core-2.1.2/lib/fog/core/service.rb:98:in `new' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/fog-core-2.1.2/lib/fog/core/services_mixin.rb:16:in `new' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:124:in `eager_load_fog' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:137:in `fog_credentials=' /home/ec2-user/environment/original_app_2/config/initializers/carrierwave.rb:8:in `block in <top (required)>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:159:in `configure' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/carrierwave-1.2.2/lib/carrierwave.rb:14:in `configure' /home/ec2-user/environment/original_app_2/config/initializers/carrierwave.rb:4:in `<top (required)>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/engine.rb:655:in `block in load_config_initializer' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/notifications.rb:168:in `instrument' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/engine.rb:654:in `load_config_initializer' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/engine.rb:611:in `each' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/engine.rb:611:in `block in <class:Engine>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/initializable.rb:48:in `each' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/initializable.rb:48:in `tsort_each_child' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!' /home/ec2-user/environment/original_app_2/config/environment.rb:5:in `<top (required)>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/application.rb:445:in `block in run_tasks_blocks' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/commands/rake/rake_command.rb:21:in `block in perform' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/commands/rake/rake_command.rb:18:in `perform' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/command.rb:46:in `invoke' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>' /home/ec2-user/environment/original_app_2/bin/rails:9:in `require' /home/ec2-user/environment/original_app_2/bin/rails:9:in `<top (required)>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/client.rb:30:in `run' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/bin/spring:49:in `<top (required)>' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>' /home/ec2-user/environment/original_app_2/bin/spring:15:in `require' /home/ec2-user/environment/original_app_2/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Tasks: TOP => db:migrate => environment (See full trace by running task with --trace) ### 該当のソースコード /config/initializers/carrierwave.rb require 'carrierwave/storage/abstract' require 'carrierwave/storage/file' require 'carrierwave/storage/fog' CarrierWave.configure do |config| config.storage :fog config.fog_provider = 'fog/aws' config.fog_credentials = { provider: 'AWS', aws_access_key_id: 'アクセスキーID', aws_access_key_id: 'シークレットアクセスキーID', use_iam_profile: true, region: 'リージョン名', path_style: true } config.fog_directory = 'バケット名' end /config/secrets.yml development: secret_key_base: ~~~ aws_access_key_id: 'アクセスキーID' aws_secret_access_key: 'シークレットアクセスキーID' test: secret_key_base: ~~~ aws_access_key_id: 'アクセスキーID' aws_secret_access_key: 'シークレットアクセスキーID' production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> aws_access_key_id: 'アクセスキーID' aws_secret_access_key: 'シークレットアクセスキーID' ```ここに言語名を入力 ソースコード
試したこと
アクセスキーやIAMユーザー、S3バケットの再作成・登録
carrierwave.rbやsecrets.ymlファイルの変更
補足情報(FW/ツールのバージョンなど)
とりあえず、開発環境では 保存先を storage :file にしていれば機能します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/09/11 08:21
2019/09/11 08:44 編集
2019/09/11 08:47
2019/09/11 09:02
2019/09/11 09:11