aws_config_rule – Manage AWS Config resources

New in version 2.6.

Synopsis

  • Module manages AWS Config rules

Requirements

The below requirements are needed on the host that executes this module.

  • boto

  • boto3

  • botocore

  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
aws_access_key
string
AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used.

aliases: ec2_access_key, access_key
aws_secret_key
string
AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used.

aliases: ec2_secret_key, secret_key
debug_botocore_endpoint_logs
boolean
added in 2.8
    Choices:
  • no ←
  • yes
Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used.
description
-
The description that you provide for the AWS Config rule.
ec2_url
string
Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used.
execution_frequency
-
    Choices:
  • One_Hour
  • Three_Hours
  • Six_Hours
  • Twelve_Hours
  • TwentyFour_Hours
The maximum frequency with which AWS Config runs evaluations for a rule.
input_parameters
-
A string, in JSON format, that is passed to the AWS Config rule Lambda function.
name
- / required
The name of the AWS Config resource.
profile
string
Uses a boto profile. Only works with boto >= 2.24.0.
region
string
The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region

aliases: aws_region, ec2_region
scope
-
Defines which resources can trigger an evaluation for the rule.
compliance_id
-
The ID of the only AWS resource that you want to trigger an evaluation for the rule. If you specify a resource ID, you must specify one resource type for `compliance_types`.
compliance_types
-
The resource types of only those AWS resources that you want to trigger an evaluation for the rule. You can only specify one type if you also specify a resource ID for `compliance_id`.
tag_key
-
The tag key that is applied to only those AWS resources that you want to trigger an evaluation for the rule.
tag_value
-
The tag value applied to only those AWS resources that you want to trigger an evaluation for the rule. If you specify a value for `tag_value`, you must also specify a value for `tag_key`.
security_token
string
AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.

aliases: access_token
source
-
Provides the rule owner (AWS or customer), the rule identifier, and the notifications that cause the function to evaluate your AWS resources.
details
-
Provides the source and type of the event that causes AWS Config to evaluate your AWS resources.
This parameter expects a list of dictionaries. Each dictionary expects the following key/value pairs.
Key `EventSource` The source of the event, such as an AWS service, that triggers AWS Config to evaluate your AWS resources.
Key `MessageType` The type of notification that triggers AWS Config to run an evaluation for a rule.
Key `MaximumExecutionFrequency` The frequency at which you want AWS Config to run evaluations for a custom rule with a periodic trigger.
identifier
-
The ID of the only AWS resource that you want to trigger an evaluation for the rule. If you specify a resource ID, you must specify one resource type for `compliance_types`.
owner
-
The resource types of only those AWS resources that you want to trigger an evaluation for the rule. You can only specify one type if you also specify a resource ID for `compliance_id`.
state
-
    Choices:
  • present ←
  • absent
Whether the Config rule should be present or absent.
validate_certs
boolean
    Choices:
  • no
  • yes ←
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.

Notes

Note

  • If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence AWS_URL or EC2_URL, AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY or EC2_ACCESS_KEY, AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY or EC2_SECRET_KEY, AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN, AWS_REGION or EC2_REGION

  • Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See https://boto.readthedocs.io/en/latest/boto_config_tut.html

  • AWS_REGION or EC2_REGION can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file

Examples

- name: Create Config Rule for AWS Config
  aws_config_rule:
    name: test_config_rule
    state: present
    description: 'This AWS Config rule checks for public write access on S3 buckets'
    scope:
        compliance_types:
            - 'AWS::S3::Bucket'
    source:
        owner: AWS
        identifier: 'S3_BUCKET_PUBLIC_WRITE_PROHIBITED'

Status

Authors

  • Aaron Smith (@slapula)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.