github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/aws/r/config_config_rule.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_config_config_rule"
     4  sidebar_current: "docs-aws-resource-config-config-rule"
     5  description: |-
     6    Provides an AWS Config Rule.
     7  ---
     8  
     9  # aws\_config\_config\_rule
    10  
    11  Provides an AWS Config Rule.
    12  
    13  ~> **Note:** Config Rule requires an existing [Configuration Recorder](/docs/providers/aws/r/config_configuration_recorder.html) to be present. Use of `depends_on` is recommended (as shown below) to avoid race conditions.
    14  
    15  ## Example Usage
    16  
    17  ```hcl
    18  resource "aws_config_config_rule" "r" {
    19    name = "example"
    20  
    21    source {
    22      owner             = "AWS"
    23      source_identifier = "S3_BUCKET_VERSIONING_ENABLED"
    24    }
    25  
    26    depends_on = ["aws_config_configuration_recorder.foo"]
    27  }
    28  
    29  resource "aws_config_configuration_recorder" "foo" {
    30    name     = "example"
    31    role_arn = "${aws_iam_role.r.arn}"
    32  }
    33  
    34  resource "aws_iam_role" "r" {
    35    name = "my-awsconfig-role"
    36  
    37    assume_role_policy = <<POLICY
    38  {
    39    "Version": "2012-10-17",
    40    "Statement": [
    41      {
    42        "Action": "sts:AssumeRole",
    43        "Principal": {
    44          "Service": "config.amazonaws.com"
    45        },
    46        "Effect": "Allow",
    47        "Sid": ""
    48      }
    49    ]
    50  }
    51  POLICY
    52  }
    53  
    54  resource "aws_iam_role_policy" "p" {
    55    name = "my-awsconfig-policy"
    56    role = "${aws_iam_role.r.id}"
    57  
    58    policy = <<POLICY
    59  {
    60    "Version": "2012-10-17",
    61    "Statement": [
    62    	{
    63    		"Action": "config:Put*",
    64    		"Effect": "Allow",
    65    		"Resource": "*"
    66  
    67    	}
    68    ]
    69  }
    70  POLICY
    71  }
    72  ```
    73  
    74  ## Argument Reference
    75  
    76  The following arguments are supported:
    77  
    78  * `name` - (Required) The name of the rule
    79  * `description` - (Optional) Description of the rule
    80  * `input_parameters` - (Optional) A string in JSON format that is passed to the AWS Config rule Lambda function (only valid if `source.owner` is `CUSTOM_LAMBDA`).
    81  * `maximum_execution_frequency` - (Optional) The maximum frequency with which AWS Config runs evaluations for a rule.
    82  * `scope` - (Optional) Scope defines which resources can trigger an evaluation for the rule as documented below.
    83  * `source` - (Required) Source specifies the rule owner, the rule identifier, and the notifications that cause
    84  	the function to evaluate your AWS resources as documented below.
    85  
    86  ### `scope`
    87  
    88  Defines which resources can trigger an evaluation for the rule.
    89  If you do not specify a scope, evaluations are triggered when any resource in the recording group changes.
    90  
    91  * `compliance_resource_id` - (Optional) The IDs of the only AWS resource that you want to trigger an evaluation for the rule.
    92  	If you specify a resource ID, you must specify one resource type for `compliance_resource_types`.
    93  * `compliance_resource_types` - (Optional) A list of resource types of only those AWS resources that you want to trigger an
    94  	evaluation for the rule. e.g. `AWS::EC2::Instance`. You can only specify one type if you also specify
    95  	a resource ID for `compliance_resource_id`. See [relevant part of AWS Docs](http://docs.aws.amazon.com/config/latest/APIReference/API_ResourceIdentifier.html#config-Type-ResourceIdentifier-resourceType) for available types.
    96  * `tag_key` - (Optional, Required if `tag_value` is specified) The tag key that is applied to only those AWS resources that you want you
    97  	want to trigger an evaluation for the rule.
    98  * `tag_value` - (Optional) The tag value applied to only those AWS resources that you want to trigger an evaluation for the rule.
    99  
   100  ### `source`
   101  
   102  Provides the rule owner (AWS or customer), the rule identifier, and the notifications that cause the function to evaluate your AWS resources.
   103  
   104  * `owner` - (Required) Indicates whether AWS or the customer owns and manages the AWS Config rule.
   105  	The only valid value is `AWS` or `CUSTOM_LAMBDA`. Keep in mind that Lambda function will require `aws_lambda_permission` to allow AWSConfig to execute the function.
   106  * `source_identifier` - (Required) For AWS Config managed rules, a predefined identifier from a list. For example,
   107  	`IAM_PASSWORD_POLICY` is a managed rule. To reference a managed rule, see [Using AWS Managed Config Rules](http://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_use-managed-rules.html).
   108  	For custom rules, the identifier is the ARN of the rule's AWS Lambda function, such as `arn:aws:lambda:us-east-1:123456789012:function:custom_rule_name`.
   109  * `source_detail` - (Optional) Provides the source and type of the event that causes AWS Config to evaluate your AWS resources. Only valid if `owner` is `CUSTOM_LAMBDA`.
   110  	* `event_source` - (Optional) The source of the event, such as an AWS service, that triggers AWS Config
   111  		to evaluate your AWS resources. This defaults to `aws.config` and is the only valid value.
   112  	* `maximum_execution_frequency` - (Optional) The frequency that you want AWS Config to run evaluations for a rule that
   113  		is triggered periodically. If specified, requires `message_type` to be `ScheduledNotification`.
   114  	* `message_type` - (Optional) The type of notification that triggers AWS Config to run an evaluation for a rule. You can specify the following notification types:
   115  	    * `ConfigurationItemChangeNotification` - Triggers an evaluation when AWS
   116  	    	Config delivers a configuration item as a result of a resource change.
   117  	    * `OversizedConfigurationItemChangeNotification` - Triggers an evaluation
   118  	    	when AWS Config delivers an oversized configuration item. AWS Config may
   119  	    	generate this notification type when a resource changes and the notification
   120  	    	exceeds the maximum size allowed by Amazon SNS.
   121  	    * `ScheduledNotification` - Triggers a periodic evaluation at the frequency
   122  	    	specified for `maximum_execution_frequency`.
   123  	    * `ConfigurationSnapshotDeliveryCompleted` - Triggers a periodic evaluation
   124  	    	when AWS Config delivers a configuration snapshot.
   125  
   126  ## Attributes Reference
   127  
   128  The following attributes are exported:
   129  
   130  * `arn` - The ARN of the config rule
   131  * `rule_id` - The ID of the config rule
   132  
   133  ## Import
   134  
   135  Config Rule can be imported using the name, e.g.
   136  
   137  ```
   138  $ terraform import aws_config_config_rule.foo example
   139  ```