0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「Unable to find AWS credentials~」のエラー出た

Posted at

下記のサイトを参考にZabbixでAWS/CloudWatchの監視設定するも
アイテムのステータスが取得不可となり「Credentials.Unable to find AWS credentials」のエラーが出た

■参考サイト
http://dev.classmethod.jp/cloud/aws/zabbix-with-cloudwatch/

■エラー内容

Received value [/usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/credential_providers.rb:140:in `credentials': (AWS::Errors::MissingCredentialsError)Missing Credentials.Unable to find AWS credentials. You can configure your AWS credentialsa few different ways:* Call AWS.config with :access_key_id and :secret_access_key* Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to ENV* On EC2 you can run instances with an IAM instance profile and credentials will be auto loaded from the instance metadata service on those instances.* Call AWS.config with :credential_provider. A credential provider should either include AWS::Core::CredentialProviders::Provider or respond to the same public methods.= Ruby on RailsIn a Ruby on Rails application you may also specify your credentials inthe following ways:* Via a config initializer script using any of the methods mentioned above (e.g. RAILS_ROOT/config/initializers/aws-sdk.rb).* Via a yaml configuration file located at RAILS_ROOT/config/aws.yml. This file should be formated like the default RAILS_ROOT/config/database.yml file.	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/credential_providers.rb:62:in `access_key_id'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/client.rb:549:in `build_request'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/client.rb:491:in `block (3 levels) in client_request'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/response.rb:175:in `call'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/response.rb:175:in `build_request'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/response.rb:114:in `initialize'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/client.rb:203:in `new'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/client.rb:203:in `new_response'	from /usr/local/share/ruby/gems/2.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/client.rb:49

credentialsの設定を見直したり、.bash_profileにAWS_SECRET_ACCESS_KEYやAWS_SECRET_ACCESS_KEYのexportを入れたしたけど、ダメだったので
/usr/lib/zabbix/externalscripts/にconfig.ymlを作成して以下の設定をし
ruby実行スクリプトの中に以下を追加したらセキュリティ的にベストじゃないけどもWEBUI上でエラーがなくなった。

■config.yml

access_key_id: *****************
secret_access_key: *****************

■/usr/lib/zabbix/externalscripts/cloud_watchに追加

require 'yaml'

config = YAML.load(File.read("config.yml"))
AWS.config(config)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?