Created
May 21, 2012 13:04
-
-
Save cjs226/2762221 to your computer and use it in GitHub Desktop.
Chef - How can I search this data bag for the address of the sqs queue with object_type=d, process=backup, trigger=scheduled?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "cool_app-v1-production", | |
"product": "cool_app", | |
"version": "1", | |
"environment": "production", | |
"db": [ | |
{ "id": "db23", | |
"host": "db23.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db46", | |
"host": "db46.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db98", | |
"host": "db98.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db12", | |
"host": "db12.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db143", | |
"host": "db143.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db99", | |
"host": "db99.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db7", | |
"host": "db7.xyz.us-east-1.rds.amazonaws.com", | |
"type": "data" }, | |
{ "id": "db2", | |
"host": "db2.xyz.us-east-1.rds.amazonaws.com", | |
"type": "index" } | |
], | |
"sqs": [ | |
{ "id": "sqs_00", | |
"address": "https://queue.amazonaws.com/xyz/sqs_00", | |
"object_type": "d", | |
"process": "backup", | |
"trigger": "on_demand" }, | |
{ "id": "sqs_78", | |
"address": "https://queue.amazonaws.com/xyz/sqs_78", | |
"object_type": "d", | |
"process": "restore", | |
"trigger": "on_demand" }, | |
{ "id": "sqs_77", | |
"address": "https://queue.amazonaws.com/xyz/sqs_77", | |
"object_type": "d", | |
"process": "backup", | |
"trigger": "scheduled" }, | |
{ "id": "sqs76", | |
"address": "https://queue.amazonaws.com/xyz/sqs_76", | |
"object_type": "e", | |
"process": "backup", | |
"trigger": "on_demand" }, | |
{ "id": "sqs_75", | |
"address": "https://queue.amazonaws.com/xyz/sqs_75", | |
"object_type": "e", | |
"process": "restore", | |
"trigger": "on_demand" }, | |
{ "id": "sqs_74", | |
"address": "https://queue.amazonaws.com/xyz/sqs_74", | |
"object_type": "e", | |
"process": "backup", | |
"trigger": "scheduled" } | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks to yfeldblum from the chef IRC channel who provided the query:
dbi = data_bag_item("my-data-bag", "my-data-bag-item") ; sqs = dbi["sqs"].find{|hash| hash["object_type"] == "d" && hash["process"] == "backup" && hash["trigger"] == "scheduled"} ; sqs && sqs["address"]