AWS Systems Manager
User Guide

Using Chef InSpec Profiles with Systems Manager Compliance

Systems Manager now integrates with Chef InSpec. InSpec is an open-source, runtime framework that enables you to create human-readable profiles on GitHub or Amazon S3. Then you can use Systems Manager to run compliance scans and view compliant and noncompliant instances. A profile is a security, compliance, or policy requirement for your computing environment. For example, you can create profiles that perform the following checks when you scan your instances with Systems Manager Compliance:

  • Check if specific ports are open or closed.

  • Check if specific applications are running.

  • Check if certain packages are installed.

  • Check Windows Registry keys for specific properties.

You can create InSpec profiles for Amazon EC2 instances and on-premises servers or virtual machines (VMs) that you manage with Systems Manager. The following sample Chef InSpec profile checks to see if port 22 is open.

control 'Scan Port' do impact 10.0 title 'Server: Configure the service port' desc 'Always specify which port the SSH server should listen to. Prevent unexpected settings.' describe sshd_config do its('Port') { should eq('22') } end end

InSpec includes a collection of resources that help you quickly write checks and auditing controls. InSpec uses the InSpec Domain-specific Language (DSL) for writing these controls in Ruby. You can also use profiles created by a large community of InSpec users. For example, the DevSec chef-os-hardening project on GitHub includes dozens of profiles to help you secure your instances and servers. You can author and store profiles in GitHub or Amazon Simple Storage Service (Amazon S3).

How It Works

Here is how the process of using InSpec profiles with Systems Manager Compliance works.

  1. Either identify predefined InSpec profiles that you want to use, or create your own. You can use predefined profiles on GitHub to get started. For information about how to create your own InSpec profiles, see Compliance Automation with InSpec.

  2. Store profiles in either a public or private GitHub repository, or in an Amazon S3 bucket.

  3. Run Compliance with your InSpec profiles by using the AWS-RunInspecChecks SSM document. You can begin a Compliance scan by using Run Command (for on-demand scans), or you can schedule regular Compliance scans by using State Manager.

  4. Identify noncompliant instances by using the Compliance API or the Systems Manager Compliance console.


Chef uses a client on your instances to process the profile. You don't need to install the client. When Systems Manager runs the AWS-RunInspecChecks SSM document, the system checks if the client is installed. If not, Systems Manager installs the Chef client during the scan, and then uninstalls the client after the scan is completed.

Running an InSpec Compliance Scan

This section includes information about how to run an InSpec Compliance scan by using the Systems Manager console and the AWS CLI. The console procedure shows you how to configure State Manager to run the scan. The AWS CLI procedure shows you how to configure Run Command to run the scan.

Running an InSpec Compliance Scan with State Manager by Using the Console

To run an InSpec Compliance scan with State Manager by using the AWS Systems Manager console

  1. Open the AWS Systems Manager console at

  2. In the navigation pane, choose State Manager.


    If the AWS Systems Manager home page opens first, choose the menu icon ( ) to open the navigation pane, and then choose State Manager.

  3. Choose Create Association.

  4. In the Provide association details section, enter a name.

  5. In the Command document list, choose AWS-RunInspecChecks.

  6. In the Document version list, choose Latest at runtime.

  7. In the Parameters section, in the Source Type list, choose either GitHub or S3.

    If you choose GitHub, then enter the path to an InSpec profile in either a public or private GitHub repository in the Source Info field. Here is an example path to a public profile provided by the Systems Manager team from the following location:


    If you choose S3, then enter a valid URL to an InSpec profile in an Amazon S3 bucket in the Source Info field.

    For more information about how Systems Manager integrates with GitHub and Amazon S3, see Running Scripts from GitHub and Amazon S3.

  8. In the Targets section, identify the instances on which you want to run this operation by specifying tags, selecting instances manually, or specifying a resource group.


    If you choose to select instances manually, and an instance you expect to see is not included in the list, see Where Are My Instances? for troubleshooting tips.

  9. In the Specify schedule section, use the schedule builder options to create a schedule for when you want the Compliance scan to run.

  10. In the Output options section, if you want to save the command output to a file, select the Write command output to an Amazon S3 bucket. Type the bucket and prefix (folder) names in the boxes.


    The S3 permissions that grant the ability to write the data to an S3 bucket are those of the instance profile assigned to the instance, not those of the IAM user performing this task. For more information, see Create an IAM Instance Profile for Systems Manager.

  11. Choose Create Association. The system creates the association and automatically runs the Compliance scan.

  12. Wait several minutes for the scan to complete, and then choose Compliance in the navigation pane.

  13. In Corresponding managed instances, locate instances where the Compliance Type column is Custom:Inspec.

  14. Choose an instance ID to view the details of noncompliant statuses.

Running an InSpec Compliance Scan with Run Command by Using the AWS CLI

  1. Install and configure the AWS CLI, if you have not already.

    For information, see Install or Upgrade the AWS CLI.

  2. Run one of the following commands to run an InSpec profile from either GitHub or Amazon S3.

    The command takes the following parameters:

    • sourceType: GitHub or Amazon S3

    • sourceInfo: URL to the InSpec profile folder either in GitHub or an Amazon S3 bucket. The folder must contain the base InSpec file (*.yml) and all related controls (*.rb).


    aws ssm send-command --document-name "AWS-RunInspecChecks" --targets '[{"Key":"tag:tag_name","Values":["tag_value"]}]' --parameters '{"sourceType":["GitHub"],"sourceInfo":["{\"owner\":\"owner_name\", \"repository\":\"repository_name\", \"path\": \"Inspec.yml_file"}"]}'

    Here is an example.

    aws ssm send-command --document-name "AWS-RunInspecChecks" --targets '[{"Key":"tag:testEnvironment","Values":["webServers"]}]' --parameters '{"sourceType":["GitHub"],"getOptions":"branch:master","sourceInfo":["{\"owner\":\"awslabs\", \"repository\":\"amazon-ssm\", \"path\": \"Compliance/InSpec/PortCheck\"}"]}'

    Amazon S3

    aws ssm send-command --document-name "AWS-RunInspecChecks" --targets '[{"Key":"tag:tag_name","Values":["tag_value"]}]' --parameters'{"sourceType":["S3"],"sourceInfo":["{\"path\":\"\"}"]}'

    Here is an example.

    aws ssm send-command --document-name "AWS-RunInspecChecks" --targets '[{"Key":"tag:testEnvironment","Values":["webServers"]}]' --parameters'{"sourceType":["S3"],"sourceInfo":["{\"path\":\"\"}"]}'
  3. Run the following command to view a summary of the Compliance scan.

    aws ssm list-resource-compliance-summaries --filters Key=ComplianceType,Values=Custom:Inspec
  4. Run the following command to drill down into an instance that is not compliant.

    aws ssm list-compliance-items --resource-ids instance_ID --resource-type ManagedInstance --filters Key=DocumentName,Values=AWS-RunInspecChecks

Related AWS Services

The following related services can help you assess Compliance and work with Chef.

  • Amazon Inspector lets you perform security assessments on your instances based on and common vulnerabilities described in Central Internet Security (CIS) standards.

  • AWS OpsWorks for Chef Automate lets you run a Chef Automate server in AWS.