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

Required argument access_key is missing #5

Open
paulius005 opened this issue May 13, 2017 · 5 comments
Open

Required argument access_key is missing #5

paulius005 opened this issue May 13, 2017 · 5 comments

Comments

@paulius005
Copy link

paulius005 commented May 13, 2017

chef_handler_sns-cookbook version 3.0.0

I have taken the aws-opsworks-service-role and aws-opsworks-ec2-role roles and added the following policies to them

for aws-opsworks-service-role:
screen shot 2017-05-12 at 8 09 24 pm

At the stack level:
the IAM role is :aws-opsworks-service-role
and the Default IAM instance profile is: aws-opsworks-ec2-role

with SNSPublish containing the following:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1494612602000",
            "Effect": "Allow",
            "Action": [
                "sns:Publish"
            ],
            "Resource": [
                "arn:aws:sns:us-west-1:123412341234:opsworks-handler-notifications"
            ]
        }
    ]
}

I am running this recipe in my own recipe in the following way:

chef_handler_sns 'arn:aws:sns:us-west-1:123412341234:opsworks-handler-notifications

All the default values are left as provided in chef_handler_sns/attributes/default.rb

But I keep getting the following: Required argument access_key is missing!

[2017-05-13T01:54:24+00:00] ERROR: Report handler Chef::Handler::Sns raised #<Chef::Exceptions::ValidationFailed: Required argument access_key is missing!>
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-handler-sns-2.1.0/lib/chef/handler/sns/config.rb:109:in `block in config_check'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-handler-sns-2.1.0/lib/chef/handler/sns/config.rb:107:in `each'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-handler-sns-2.1.0/lib/chef/handler/sns/config.rb:107:in `config_check'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-handler-sns-2.1.0/lib/chef/handler/sns.rb:134:in `report'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/handler.rb:259:in `run_report_unsafe'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/handler.rb:247:in `run_report_safely'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/handler.rb:125:in `block in run_report_handlers'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/handler.rb:123:in `each'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/handler.rb:123:in `run_report_handlers'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/handler.rb:135:in `block in <class:Handler>'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:441:in `block in run_completed_successfully'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:440:in `each'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:440:in `run_completed_successfully'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:299:in `run'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:295:in `block in fork_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:283:in `fork'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:283:in `fork_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:248:in `block in run_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/local_mode.rb:44:in `with_server_connectivity'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:236:in `run_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:450:in `loop'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:450:in `interval_run_chef_client'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:434:in `run_application'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:59:in `run'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/bin/chef-client:26:in `<top (required)>'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/bin/chef-client:57:in `load'
[2017-05-13T01:54:24+00:00] ERROR: /opt/chef/bin/chef-client:57:in `<main>'

Is there a way to not have to provide an access_key and secret_key? Is there something else I should check

@zuazo
Copy link
Owner

zuazo commented May 13, 2017

Seems like maybe chef-handler-sns is not reading the IAM credentials from ohai correctly. Could you share you Ohai version and output of ohai command? (of course, blur your credentials before posting its output here).

@paulius005
Copy link
Author

paulius005 commented May 13, 2017

Ohai version: 5.1.0. output obfuscated and attached :)
output.txt

@zuazo
Copy link
Owner

zuazo commented May 14, 2017

Thanks for the information 😉

Try enabling iam hint in Ohai. See #3.

@paulius005
Copy link
Author

paulius005 commented May 14, 2017

Ah yep.

directory '/etc/chef/ohai/hints' do
  action :nothing
  recursive true
end.run_action(:create)

file '/etc/chef/ohai/hints/iam.json' do
  content '{}'
  action :nothing
end.run_action(:create)

ohai "reload" do
  action :nothing
end.run_action(:reload)

threw that into the recipe and I was good.

Thanks for your help!

Want me to add a section in the readme explaining that this must be enabled?

@zuazo
Copy link
Owner

zuazo commented May 14, 2017

Thanks for your feedback! 😄

I'm thinking that maybe we should add that code directly to the cookbook. What do you think?

Another possibility is to use the ohai_hint resource from the ohai cookbook:

ohai_hint 'iam'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants