Use Inspec custom resource in a different cookbook


Hi here, I am new with Inspec. Let’s say I created a inspec custom resource like the one in this example in a cookbook.

How can I use that resource in other cookbooks? It seems that adding that cookbook to the kitchen.yml it is not sufficient.

I am reading about profile dependencies, but I am not sure if that is the way to go in this scenario.

Thanks for the help


Hi, Gonzalo!

In order to use custom resources from another profile, you must declare that profile as a dependency. This is done by modifying your including-profile’s inspec.yml file. We have a section on this very thing on our website here:

I will give you a word of caution though: currently, when InSpec fetches a profile dependency via git or URL, it expects that the profile is in the top-level of that repo/URL. If the profile you’re trying to include is a few directories deep (i.e. in a cookbook), it won’t work. We currently an open feature-request on that very functionality but it is not yet implemented:

So my recommendation would be to pull that profile out of your cookbook, put it in a separate repo, and then you can include it from within other profiles, and you can still include it in your cookbook’s .kitchen.yml file, like this example:

  name: inspec
    - name: my_cookbook_profile

I hope that helps!
~Adam :slight_smile:


Hey Adam, thanks for the quick replay!

Yeah, that helps a lot!

Thanks again