amazon-web-serviceschef-infraaws-opsworksdatabags

AWS Opsworks where to put data_bag folder?


I am using AWS Opsworks with Chef 12 and custom cookbooks. I would like to use data_bags also, but I can't figure out where Opsworks looks for them.

If I add them the /var/chef/data_bags I can successfully run the recipes using chef-client --local-mode, However when I try via the Opsworks -> Stack -> Execute recipe I get the follow error.

[2016-01-07T21:05:07+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/data/users

It seems that OpsWorks creates its own data_bags at this location /var/chef/runs/9586fca2-52d1-43a8-9b3c-6fc0e4e79259/data_bags However these are all custom AWS folders eg..

aws_opsworks_app      aws_opsworks_ecs_cluster            aws_opsworks_instance  aws_opsworks_rds_db_instance  aws_opsworks_user
aws_opsworks_command  aws_opsworks_elastic_load_balancer  aws_opsworks_layer     aws_opsworks_stack

How can I either add to the OpsWorks Databag or where do I place my own data_bag folder?


Solution

  • http://docs.aws.amazon.com/opsworks/latest/userguide/best-practices-server-migrate.html#best-practices-server-migrate-data-bags

    http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-chef11-10.html#workingcookbook-chef11-10-databag

    So basically you need to define, inside opsworks custom jsons that you attach to the stack level or layer level, etc. Those jsons are picked up and injected in the databags that end up being part of a run. (i.e. you cannot define the bags inside of cookbooks)