Search code examples
rubychef-infraamazon-route53databags

EncryptedDataBagItem.load produces 'cannot convert nil into String'


I'm following the method described in this post for creating a DNS record for a new server as Chef provisions it. I've created an encrypted data bag item for my AWS credentials:

$ knife data bag show passwords aws --secret-file .chef/encryted_data_bag_secret 
aws_access_key: <my_access_key>
aws_secret_key: <my_secret_key>
id:             aws

However, when I run the chef client, this line...

aws_creds = Chef::EncryptedDataBagItem.load('passwords', 'aws')

produces this error:

TypeError: can't convert nil into String

I've tried searching for the error, but while I can see evidence that other people have encountered this, it's not clear what their problem was or how it was resolved. What's going on here, and how can I fix it?


Solution

  • I hit this error today too. For me, the node was missing the encrypted_data_bag_secret.

    According to this bug (http://tickets.opscode.com/browse/CHEF-4441), the error (in my case) would have been clearer in Chef 11.4.4:

    No such file or directory - file not found '/etc/chef/encrypted_data_bag_secret'
    

    I hope that's helpful.