1.. _community.aws.aws_config_rule_module:
2
3
4*****************************
5community.aws.aws_config_rule
6*****************************
7
8**Manage AWS Config resources**
9
10
11Version added: 1.0.0
12
13.. contents::
14   :local:
15   :depth: 1
16
17
18Synopsis
19--------
20- Module manages AWS Config rules
21
22
23
24Requirements
25------------
26The below requirements are needed on the host that executes this module.
27
28- boto
29- boto3
30- botocore
31- python >= 2.6
32
33
34Parameters
35----------
36
37.. raw:: html
38
39    <table  border=0 cellpadding=0 class="documentation-table">
40        <tr>
41            <th colspan="2">Parameter</th>
42            <th>Choices/<font color="blue">Defaults</font></th>
43            <th width="100%">Comments</th>
44        </tr>
45            <tr>
46                <td colspan="2">
47                    <div class="ansibleOptionAnchor" id="parameter-"></div>
48                    <b>aws_access_key</b>
49                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
50                    <div style="font-size: small">
51                        <span style="color: purple">string</span>
52                    </div>
53                </td>
54                <td>
55                </td>
56                <td>
57                        <div>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.</div>
58                        <div>If <em>profile</em> is set this parameter is ignored.</div>
59                        <div>Passing the <em>aws_access_key</em> and <em>profile</em> options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.</div>
60                        <div style="font-size: small; color: darkgreen"><br/>aliases: ec2_access_key, access_key</div>
61                </td>
62            </tr>
63            <tr>
64                <td colspan="2">
65                    <div class="ansibleOptionAnchor" id="parameter-"></div>
66                    <b>aws_ca_bundle</b>
67                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
68                    <div style="font-size: small">
69                        <span style="color: purple">path</span>
70                    </div>
71                </td>
72                <td>
73                </td>
74                <td>
75                        <div>The location of a CA Bundle to use when validating SSL certificates.</div>
76                        <div>Only used for boto3 based modules.</div>
77                        <div>Note: The CA Bundle is read &#x27;module&#x27; side and may need to be explicitly copied from the controller if not run locally.</div>
78                </td>
79            </tr>
80            <tr>
81                <td colspan="2">
82                    <div class="ansibleOptionAnchor" id="parameter-"></div>
83                    <b>aws_config</b>
84                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
85                    <div style="font-size: small">
86                        <span style="color: purple">dictionary</span>
87                    </div>
88                </td>
89                <td>
90                </td>
91                <td>
92                        <div>A dictionary to modify the botocore configuration.</div>
93                        <div>Parameters can be found at <a href='https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config'>https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config</a>.</div>
94                        <div>Only the &#x27;user_agent&#x27; key is used for boto modules. See <a href='http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto'>http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto</a> for more boto configuration.</div>
95                </td>
96            </tr>
97            <tr>
98                <td colspan="2">
99                    <div class="ansibleOptionAnchor" id="parameter-"></div>
100                    <b>aws_secret_key</b>
101                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
102                    <div style="font-size: small">
103                        <span style="color: purple">string</span>
104                    </div>
105                </td>
106                <td>
107                </td>
108                <td>
109                        <div>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.</div>
110                        <div>If <em>profile</em> is set this parameter is ignored.</div>
111                        <div>Passing the <em>aws_secret_key</em> and <em>profile</em> options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.</div>
112                        <div style="font-size: small; color: darkgreen"><br/>aliases: ec2_secret_key, secret_key</div>
113                </td>
114            </tr>
115            <tr>
116                <td colspan="2">
117                    <div class="ansibleOptionAnchor" id="parameter-"></div>
118                    <b>debug_botocore_endpoint_logs</b>
119                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
120                    <div style="font-size: small">
121                        <span style="color: purple">boolean</span>
122                    </div>
123                </td>
124                <td>
125                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
126                                    <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
127                                    <li>yes</li>
128                        </ul>
129                </td>
130                <td>
131                        <div>Use a botocore.endpoint logger to parse the unique (rather than total) &quot;resource:action&quot; 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.</div>
132                </td>
133            </tr>
134            <tr>
135                <td colspan="2">
136                    <div class="ansibleOptionAnchor" id="parameter-"></div>
137                    <b>description</b>
138                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
139                    <div style="font-size: small">
140                        <span style="color: purple">string</span>
141                    </div>
142                </td>
143                <td>
144                </td>
145                <td>
146                        <div>The description that you provide for the AWS Config rule.</div>
147                </td>
148            </tr>
149            <tr>
150                <td colspan="2">
151                    <div class="ansibleOptionAnchor" id="parameter-"></div>
152                    <b>ec2_url</b>
153                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
154                    <div style="font-size: small">
155                        <span style="color: purple">string</span>
156                    </div>
157                </td>
158                <td>
159                </td>
160                <td>
161                        <div>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.</div>
162                        <div style="font-size: small; color: darkgreen"><br/>aliases: aws_endpoint_url, endpoint_url</div>
163                </td>
164            </tr>
165            <tr>
166                <td colspan="2">
167                    <div class="ansibleOptionAnchor" id="parameter-"></div>
168                    <b>execution_frequency</b>
169                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
170                    <div style="font-size: small">
171                        <span style="color: purple">string</span>
172                    </div>
173                </td>
174                <td>
175                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
176                                    <li>One_Hour</li>
177                                    <li>Three_Hours</li>
178                                    <li>Six_Hours</li>
179                                    <li>Twelve_Hours</li>
180                                    <li>TwentyFour_Hours</li>
181                        </ul>
182                </td>
183                <td>
184                        <div>The maximum frequency with which AWS Config runs evaluations for a rule.</div>
185                </td>
186            </tr>
187            <tr>
188                <td colspan="2">
189                    <div class="ansibleOptionAnchor" id="parameter-"></div>
190                    <b>input_parameters</b>
191                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
192                    <div style="font-size: small">
193                        <span style="color: purple">string</span>
194                    </div>
195                </td>
196                <td>
197                </td>
198                <td>
199                        <div>A string, in JSON format, that is passed to the AWS Config rule Lambda function.</div>
200                </td>
201            </tr>
202            <tr>
203                <td colspan="2">
204                    <div class="ansibleOptionAnchor" id="parameter-"></div>
205                    <b>name</b>
206                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
207                    <div style="font-size: small">
208                        <span style="color: purple">string</span>
209                         / <span style="color: red">required</span>
210                    </div>
211                </td>
212                <td>
213                </td>
214                <td>
215                        <div>The name of the AWS Config resource.</div>
216                </td>
217            </tr>
218            <tr>
219                <td colspan="2">
220                    <div class="ansibleOptionAnchor" id="parameter-"></div>
221                    <b>profile</b>
222                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
223                    <div style="font-size: small">
224                        <span style="color: purple">string</span>
225                    </div>
226                </td>
227                <td>
228                </td>
229                <td>
230                        <div>Uses a boto profile. Only works with boto &gt;= 2.24.0.</div>
231                        <div>Using <em>profile</em> will override <em>aws_access_key</em>, <em>aws_secret_key</em> and <em>security_token</em> and support for passing them at the same time as <em>profile</em> has been deprecated.</div>
232                        <div><em>aws_access_key</em>, <em>aws_secret_key</em> and <em>security_token</em> will be made mutually exclusive with <em>profile</em> after 2022-06-01.</div>
233                        <div style="font-size: small; color: darkgreen"><br/>aliases: aws_profile</div>
234                </td>
235            </tr>
236            <tr>
237                <td colspan="2">
238                    <div class="ansibleOptionAnchor" id="parameter-"></div>
239                    <b>region</b>
240                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
241                    <div style="font-size: small">
242                        <span style="color: purple">string</span>
243                    </div>
244                </td>
245                <td>
246                </td>
247                <td>
248                        <div>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 <a href='http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region'>http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region</a></div>
249                        <div style="font-size: small; color: darkgreen"><br/>aliases: aws_region, ec2_region</div>
250                </td>
251            </tr>
252            <tr>
253                <td colspan="2">
254                    <div class="ansibleOptionAnchor" id="parameter-"></div>
255                    <b>scope</b>
256                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
257                    <div style="font-size: small">
258                        <span style="color: purple">dictionary</span>
259                    </div>
260                </td>
261                <td>
262                </td>
263                <td>
264                        <div>Defines which resources can trigger an evaluation for the rule.</div>
265                </td>
266            </tr>
267                                <tr>
268                    <td class="elbow-placeholder"></td>
269                <td colspan="1">
270                    <div class="ansibleOptionAnchor" id="parameter-"></div>
271                    <b>compliance_id</b>
272                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
273                    <div style="font-size: small">
274                        <span style="color: purple">-</span>
275                    </div>
276                </td>
277                <td>
278                </td>
279                <td>
280                        <div>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 <em>compliance_types</em>.</div>
281                </td>
282            </tr>
283            <tr>
284                    <td class="elbow-placeholder"></td>
285                <td colspan="1">
286                    <div class="ansibleOptionAnchor" id="parameter-"></div>
287                    <b>compliance_types</b>
288                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
289                    <div style="font-size: small">
290                        <span style="color: purple">-</span>
291                    </div>
292                </td>
293                <td>
294                </td>
295                <td>
296                        <div>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 <em>compliance_id</em>.</div>
297                </td>
298            </tr>
299            <tr>
300                    <td class="elbow-placeholder"></td>
301                <td colspan="1">
302                    <div class="ansibleOptionAnchor" id="parameter-"></div>
303                    <b>tag_key</b>
304                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
305                    <div style="font-size: small">
306                        <span style="color: purple">-</span>
307                    </div>
308                </td>
309                <td>
310                </td>
311                <td>
312                        <div>The tag key that is applied to only those AWS resources that you want to trigger an evaluation for the rule.</div>
313                </td>
314            </tr>
315            <tr>
316                    <td class="elbow-placeholder"></td>
317                <td colspan="1">
318                    <div class="ansibleOptionAnchor" id="parameter-"></div>
319                    <b>tag_value</b>
320                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
321                    <div style="font-size: small">
322                        <span style="color: purple">-</span>
323                    </div>
324                </td>
325                <td>
326                </td>
327                <td>
328                        <div>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 <em>tag_value</em>, you must also specify a value for <em>tag_key</em>.</div>
329                </td>
330            </tr>
331
332            <tr>
333                <td colspan="2">
334                    <div class="ansibleOptionAnchor" id="parameter-"></div>
335                    <b>security_token</b>
336                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
337                    <div style="font-size: small">
338                        <span style="color: purple">string</span>
339                    </div>
340                </td>
341                <td>
342                </td>
343                <td>
344                        <div>AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.</div>
345                        <div>If <em>profile</em> is set this parameter is ignored.</div>
346                        <div>Passing the <em>security_token</em> and <em>profile</em> options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.</div>
347                        <div style="font-size: small; color: darkgreen"><br/>aliases: aws_security_token, access_token</div>
348                </td>
349            </tr>
350            <tr>
351                <td colspan="2">
352                    <div class="ansibleOptionAnchor" id="parameter-"></div>
353                    <b>source</b>
354                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
355                    <div style="font-size: small">
356                        <span style="color: purple">dictionary</span>
357                         / <span style="color: red">required</span>
358                    </div>
359                </td>
360                <td>
361                </td>
362                <td>
363                        <div>Provides the rule owner (AWS or customer), the rule identifier, and the notifications that cause the function to evaluate your AWS resources.</div>
364                </td>
365            </tr>
366                                <tr>
367                    <td class="elbow-placeholder"></td>
368                <td colspan="1">
369                    <div class="ansibleOptionAnchor" id="parameter-"></div>
370                    <b>details</b>
371                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
372                    <div style="font-size: small">
373                        <span style="color: purple">-</span>
374                    </div>
375                </td>
376                <td>
377                </td>
378                <td>
379                        <div>Provides the source and type of the event that causes AWS Config to evaluate your AWS resources.</div>
380                        <div>This parameter expects a list of dictionaries.  Each dictionary expects the following key/value pairs.</div>
381                        <div>Key `EventSource` The source of the event, such as an AWS service, that triggers AWS Config to evaluate your AWS resources.</div>
382                        <div>Key `MessageType` The type of notification that triggers AWS Config to run an evaluation for a rule.</div>
383                        <div>Key `MaximumExecutionFrequency` The frequency at which you want AWS Config to run evaluations for a custom rule with a periodic trigger.</div>
384                </td>
385            </tr>
386            <tr>
387                    <td class="elbow-placeholder"></td>
388                <td colspan="1">
389                    <div class="ansibleOptionAnchor" id="parameter-"></div>
390                    <b>identifier</b>
391                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
392                    <div style="font-size: small">
393                        <span style="color: purple">-</span>
394                    </div>
395                </td>
396                <td>
397                </td>
398                <td>
399                        <div>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 <em>compliance_types</em>.</div>
400                </td>
401            </tr>
402            <tr>
403                    <td class="elbow-placeholder"></td>
404                <td colspan="1">
405                    <div class="ansibleOptionAnchor" id="parameter-"></div>
406                    <b>owner</b>
407                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
408                    <div style="font-size: small">
409                        <span style="color: purple">-</span>
410                    </div>
411                </td>
412                <td>
413                </td>
414                <td>
415                        <div>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 <em>compliance_id</em>.</div>
416                </td>
417            </tr>
418
419            <tr>
420                <td colspan="2">
421                    <div class="ansibleOptionAnchor" id="parameter-"></div>
422                    <b>state</b>
423                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
424                    <div style="font-size: small">
425                        <span style="color: purple">string</span>
426                    </div>
427                </td>
428                <td>
429                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
430                                    <li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
431                                    <li>absent</li>
432                        </ul>
433                </td>
434                <td>
435                        <div>Whether the Config rule should be present or absent.</div>
436                </td>
437            </tr>
438            <tr>
439                <td colspan="2">
440                    <div class="ansibleOptionAnchor" id="parameter-"></div>
441                    <b>validate_certs</b>
442                    <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
443                    <div style="font-size: small">
444                        <span style="color: purple">boolean</span>
445                    </div>
446                </td>
447                <td>
448                        <ul style="margin: 0; padding: 0"><b>Choices:</b>
449                                    <li>no</li>
450                                    <li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
451                        </ul>
452                </td>
453                <td>
454                        <div>When set to &quot;no&quot;, SSL certificates will not be validated for boto versions &gt;= 2.6.0.</div>
455                </td>
456            </tr>
457    </table>
458    <br/>
459
460
461Notes
462-----
463
464.. note::
465   - 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_PROFILE`` or ``AWS_DEFAULT_PROFILE``, ``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``, ``AWS_CA_BUNDLE``
466   - Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See https://boto.readthedocs.io/en/latest/boto_config_tut.html
467   - ``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
468
469
470
471Examples
472--------
473
474.. code-block:: yaml
475
476    - name: Create Config Rule for AWS Config
477      community.aws.aws_config_rule:
478        name: test_config_rule
479        state: present
480        description: 'This AWS Config rule checks for public write access on S3 buckets'
481        scope:
482            compliance_types:
483                - 'AWS::S3::Bucket'
484        source:
485            owner: AWS
486            identifier: 'S3_BUCKET_PUBLIC_WRITE_PROHIBITED'
487
488
489
490
491Status
492------
493
494
495Authors
496~~~~~~~
497
498- Aaron Smith (@slapula)
499