Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Implement data source for pulling data from chef server #22

Open
msvticket opened this issue Jun 26, 2018 · 0 comments
Open

Implement data source for pulling data from chef server #22

msvticket opened this issue Jun 26, 2018 · 0 comments

Comments

@msvticket
Copy link

msvticket commented Jun 26, 2018

To easily use data stored on a chef server in terraform would be very useful.

I envision something you would call like this:

data "chef_search" "rabbitmq" {
  index = "node"
  query = "chef_environment:test AND role:rabbitmq"
  filter {
    name   = "rabbitmq"
    values = ["rabbitmq"]
  }

  filter {
    name   = "host"
    values = ["ipaddress"]
  }
  unique = true
}

data.chef_search.rabbitmq.rabbitmq.default_password and data.chef_search.rabbitmq.host would then be examples of attributes to use.

This is similar to how you would use search in a chef recipe:
https://docs.chef.io/chef_search.html#filter-search-results

One gotcha is that chef search normally return a list of results, while a terraform data source (as far as I understand) isn't allowed to do that. So that is why I introduced "unique" above, which would mean that a unique result is expected (and an error would be raised otherwise). Without "unique = true" the result would instead contain the list attribute "rows" with all the results.

msvticket added a commit to deniedboarding/terraform-provider-chef that referenced this issue Jun 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants