Load chef databag item in attribute file


I have the following datadog which I need to call/load from attribute file, instead of recipe files. As per few stackoverflow posts only " chef::DataBagItem.load" method need to be used if we want load from attribute file.

databag name: infrastructure-jwn-license
"id": "infrastructure-jwn-license",
"infrastructure-jwn-license-key": "ProductionKeyString",
"infrastructure-dev-jwn-license-key": "DevKeyString"

Calling as:
couchbase = Chef::DataBagItem.load('infrastructure-jwn-license', 'infrastructure-jwn-license')


404 "Not Found"

Not sure If I have missed something.

Hello gangadhar01a,
The 404 error is telling me the databag does not exist on the chef server. Have you confirmed it exists on the server or are you doing this in a local env using kitchen? The other think is that your data bag name and data bag item name are the same. I typically name the data bag something general and the item specific. I'm not sure if using the same name for both would cause this problem but it might be worth trying to rename say data bag to "licences"


1 Like

Yes, George. There is a typo when I was creating the databag.
Thank you.