# Data bag Creation

**URL:** <https://discourse.chef.io/t/data-bag-creation/5941>\
**Category:** Chef Infra (archive)\
**Created:** [November 17, 2014, 1:58am UTC](https://discourse.chef.io/t/data-bag-creation/5941 "2014-11-17T01:58:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [November 17, 2014, 1:58am UTC](https://discourse.chef.io/t/data-bag-creation/5941/1 "2014-11-17T01:58:50Z")

</div>

I have nothing but troubles with data bags. The docs have an example for  
creating an encrypted data bag:

knife data bag from file my\_data\_bag /path/to/data\_bag\_item.json -z  
–secret-file /path/to/encrypted\_data\_bag\_secret

My version is:

knife data bag from file aws\_sg aws\_sg/creds.json --secret foobar

Chef is returning:

ERROR: The object you are looking for could not be found  
Response: No data bag ‘aws\_sg’ could be found. Please create this data bag  
before adding items to it.

My file is:  
wsip-70-164-152-148:chef-sauce doug$ cat data\_bags/aws\_sg/creds.json  
{  
“id”: “creds”,  
“aws\_access\_key\_id”: “xxx”,  
“aws\_secret\_access\_key”: “yyy”  
}

So, what’s wrong with that? I thought that’s what I was TRYING to… ie  
create the data bag…

Doug

---

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [November 17, 2014, 2:42am UTC](https://discourse.chef.io/t/data-bag-creation/5941/2 "2014-11-17T02:42:28Z")

</div>

If the data bag 'aws\_sg' does not yet exist, you have to create it first.  
The command would be:  
knife data bag create aws\_sg

Then your command:  
knife data bag from file aws\_sg aws\_sg/creds.json --secret foobar  
...should work.

As the name implies, a data bag is a container, while the "creds.json" file  
you're trying to upload is an item to be placed in the container. If the  
container does not exist, you cannot place an item in it.

On Sun, Nov 16, 2014 at 8:58 PM, Douglas Garstang [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
wrote:

> I have nothing but troubles with data bags. The docs have an example for  
> creating an encrypted data bag:
> 
> knife data bag from file my\_data\_bag /path/to/data\_bag\_item.json -z  
> --secret-file /path/to/encrypted\_data\_bag\_secret
> 
> My version is:
> 
> knife data bag from file aws\_sg aws\_sg/creds.json --secret foobar
> 
> Chef is returning:
> 
> ERROR: The object you are looking for could not be found  
> Response: No data bag 'aws\_sg' could be found. Please create this data bag  
> before adding items to it.
> 
> My file is:  
> wsip-70-164-152-148:chef-sauce doug$ cat data\_bags/aws\_sg/creds.json  
> {  
> "id": "creds",  
> "aws\_access\_key\_id": "xxx",  
> "aws\_secret\_access\_key": "yyy"  
> }
> 
> So, what's wrong with that? I thought that's what I was TRYING to.. ie  
> create the data bag...
> 
> Doug
