# Skip the controls not required

**URL:** <https://discourse.chef.io/t/skip-the-controls-not-required/17808>\
**Category:** Chef InSpec\
**Created:** [October 15, 2020, 7:09am UTC](https://discourse.chef.io/t/skip-the-controls-not-required/17808 "2020-10-15T07:09:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashima](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Ashima](https://discourse.chef.io/u/Ashima)\
**Post date:** [October 15, 2020, 7:09am UTC](https://discourse.chef.io/t/skip-the-controls-not-required/17808/1 "2020-10-15T07:09:27Z")

</div>

I have created an inspec profile containing all the test cases I might need for my AWS account. However there is a chance that I do not have certain resources. So I want to skip the respective controls. For example: My profile contains tests for EFS. However I might choose not to use EFS for sometime. How can I skip the controls for EFS.  
I have seen that --control allows us to list the controls we want to execute. However with a large number of controls, this is very inefficient.  
Only\_if has been suggested in some places, but as per my understanding, it can be used to check packages on a machine. Here I am trying to check AWS resources.

How can this be achieved then?

---

<div class="post-metadata">

**Author:** ![stocksy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stocksy/32/2635_2.png) [@stocksy](https://discourse.chef.io/u/stocksy)\
**Post date:** [October 15, 2020, 8:46am UTC](https://discourse.chef.io/t/skip-the-controls-not-required/17808/2 "2020-10-15T08:46:44Z")

</div>

Hello Ashima -

The most common way to achieve that is with profile inheritance - see [https://docs.chef.io/inspec/profiles/#using-controls-from-an-included-profile](https://docs.chef.io/inspec/profiles/#using-controls-from-an-included-profile)

---

<div class="post-metadata">

**Author:** ![Ashima](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Ashima](https://discourse.chef.io/u/Ashima)\
**Post date:** [October 15, 2020, 10:17am UTC](https://discourse.chef.io/t/skip-the-controls-not-required/17808/3 "2020-10-15T10:17:24Z")

</div>

Thank you Stocksy. Can you please tell me in which file the include\_controls is used. I am trying to access another profile stored on the same computer and using include\_controls in my one of my .rb files. It is showing no effect. For reference, I am using the name "ec2-profile" in the include\_control.  
depends:

- name: inspec-aws  
url: [https://github.com/inspec/inspec-aws/archive/v1.29.1.tar.gz](https://github.com/inspec/inspec-aws/archive/v1.29.1.tar.gz)
- name: ec2-profile  
path: ../ec2\_sample\_inspec\_profile

---

<div class="post-metadata">

**Author:** ![stocksy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stocksy/32/2635_2.png) [@stocksy](https://discourse.chef.io/u/stocksy)\
**Post date:** [October 16, 2020, 9:26am UTC](https://discourse.chef.io/t/skip-the-controls-not-required/17808/4 "2020-10-16T09:26:31Z")

</div>

In your new `ec2-profile` profile, you add a `depends` section in `inspec.yml` that refers to `inspec-aws`.  
Then in `ec2-profile/controls/control.rb` (it can have any file name, it just needs to be a `.rb` file in the `controls` directory you can use the `include_controls` and `require_controls` statements described at [https://docs.chef.io/inspec/profiles/#using-controls-from-an-included-profile](https://docs.chef.io/inspec/profiles/#using-controls-from-an-included-profile)
