put_config_rule
(**kwargs)¶Adds or updates an Config rule to evaluate if your Amazon Web Services resources comply with your desired configurations. For information on how many Config rules you can have per account, see **Service Limits** in the Config Developer Guide .
There are two types of rules: Config Custom Rules and Config Managed Rules. You can use PutConfigRule
to create both Config custom rules and Config managed rules.
Custom rules are rules that you can create using either Guard or Lambda functions. Guard ( Guard GitHub Repository ) is a policy-as-code language that allows you to write policies that are enforced by Config Custom Policy rules. Lambda uses custom code that you upload to evaluate a custom rule. If you are adding a new Custom Lambda rule, you first need to create an Lambda function that the rule invokes to evaluate your resources. When you use PutConfigRule
to add a Custom Lambda rule to Config, you must specify the Amazon Resource Name (ARN) that Lambda assigns to the function. You specify the ARN in the SourceIdentifier
key. This key is part of the Source
object, which is part of the ConfigRule
object.
Managed rules are predefined, customizable rules created by Config. For a list of managed rules, see List of Config Managed Rules. If you are adding an Config managed rule, you must specify the rule's identifier for the SourceIdentifier
key.
For any new rule that you add, specify the ConfigRuleName
in the ConfigRule
object. Do not specify the ConfigRuleArn
or the ConfigRuleId
. These values are generated by Config for new rules.
If you are updating a rule that you added previously, you can specify the rule by ConfigRuleName
, ConfigRuleId
, or ConfigRuleArn
in the ConfigRule
data type that you use in this request.
For more information about developing and using Config rules, see Evaluating Amazon Web Services resource Configurations with Config in the Config Developer Guide .
See also: AWS API Documentation
Request Syntax
response = client.put_config_rule(
ConfigRule={
'ConfigRuleName': 'string',
'ConfigRuleArn': 'string',
'ConfigRuleId': 'string',
'Description': 'string',
'Scope': {
'ComplianceResourceTypes': [
'string',
],
'TagKey': 'string',
'TagValue': 'string',
'ComplianceResourceId': 'string'
},
'Source': {
'Owner': 'CUSTOM_LAMBDA'|'AWS'|'CUSTOM_POLICY',
'SourceIdentifier': 'string',
'SourceDetails': [
{
'EventSource': 'aws.config',
'MessageType': 'ConfigurationItemChangeNotification'|'ConfigurationSnapshotDeliveryCompleted'|'ScheduledNotification'|'OversizedConfigurationItemChangeNotification',
'MaximumExecutionFrequency': 'One_Hour'|'Three_Hours'|'Six_Hours'|'Twelve_Hours'|'TwentyFour_Hours'
},
],
'CustomPolicyDetails': {
'PolicyRuntime': 'string',
'PolicyText': 'string',
'EnableDebugLogDelivery': True|False
}
},
'InputParameters': 'string',
'MaximumExecutionFrequency': 'One_Hour'|'Three_Hours'|'Six_Hours'|'Twelve_Hours'|'TwentyFour_Hours',
'ConfigRuleState': 'ACTIVE'|'DELETING'|'DELETING_RESULTS'|'EVALUATING',
'CreatedBy': 'string',
'EvaluationModes': [
{
'Mode': 'DETECTIVE'|'PROACTIVE'
},
]
},
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
[REQUIRED]
The rule that you want to add to your account.
The name that you assign to the Config rule. The name is required if you are adding a new rule.
The Amazon Resource Name (ARN) of the Config rule.
The ID of the Config rule.
The description that you provide for the Config rule.
Defines which resources can trigger an evaluation for the rule. The scope can include one or more resource types, a combination of one resource type and one resource ID, or a combination of a tag key and value. Specify a scope to constrain the resources that can trigger an evaluation for the rule. If you do not specify a scope, evaluations are triggered when any resource in the recording group changes.
Note
The scope can be empty.
The resource types of only those Amazon Web Services 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 ComplianceResourceId
.
The tag key that is applied to only those Amazon Web Services resources that you want to trigger an evaluation for the rule.
The tag value applied to only those Amazon Web Services resources that you want to trigger an evaluation for the rule. If you specify a value for TagValue
, you must also specify a value for TagKey
.
The ID of the only Amazon Web Services resource that you want to trigger an evaluation for the rule. If you specify a resource ID, you must specify one resource type for ComplianceResourceTypes
.
Provides the rule owner ( Amazon Web Services
for managed rules, CUSTOM_POLICY
for Custom Policy rules, and CUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your Amazon Web Services resources.
Indicates whether Amazon Web Services or the customer owns and manages the Config rule.
Config Managed Rules are predefined rules owned by Amazon Web Services. For more information, see Config Managed Rules in the Config developer guide .
Config Custom Rules are rules that you can develop either with Guard ( CUSTOM_POLICY
) or Lambda ( CUSTOM_LAMBDA
). For more information, see Config Custom Rules in the Config developer guide .
For Config Managed rules, a predefined identifier from a list. For example, IAM_PASSWORD_POLICY
is a managed rule. To reference a managed rule, see List of Config Managed Rules.
For Config Custom Lambda rules, the identifier is the Amazon Resource Name (ARN) of the rule's Lambda function, such as arn:aws:lambda:us-east-2:123456789012:function:custom_rule_name
.
For Config Custom Policy rules, this field will be ignored.
Provides the source and the message types that cause Config to evaluate your Amazon Web Services resources against a rule. It also provides the frequency with which you want Config to run evaluations for the rule if the trigger type is periodic.
If the owner is set to CUSTOM_POLICY
, the only acceptable values for the Config rule trigger message type are ConfigurationItemChangeNotification
and OversizedConfigurationItemChangeNotification
.
Provides the source and the message types that trigger Config to evaluate your Amazon Web Services resources against a rule. It also provides the frequency with which you want Config to run evaluations for the rule if the trigger type is periodic. You can specify the parameter values for SourceDetail
only for custom rules.
The source of the event, such as an Amazon Web Services service, that triggers Config to evaluate your Amazon Web Services resources.
The type of notification that triggers Config to run an evaluation for a rule. You can specify the following notification types:
ConfigurationItemChangeNotification
- Triggers an evaluation when Config delivers a configuration item as a result of a resource change.OversizedConfigurationItemChangeNotification
- Triggers an evaluation when Config delivers an oversized configuration item. Config may generate this notification type when a resource changes and the notification exceeds the maximum size allowed by Amazon SNS.ScheduledNotification
- Triggers a periodic evaluation at the frequency specified for MaximumExecutionFrequency
.ConfigurationSnapshotDeliveryCompleted
- Triggers a periodic evaluation when Config delivers a configuration snapshot.If you want your custom rule to be triggered by configuration changes, specify two SourceDetail objects, one for ConfigurationItemChangeNotification
and one for OversizedConfigurationItemChangeNotification
.
The frequency at which you want Config to run evaluations for a custom rule with a periodic trigger. If you specify a value for MaximumExecutionFrequency
, then MessageType
must use the ScheduledNotification
value.
Note
By default, rules with a periodic trigger are evaluated every 24 hours. To change the frequency, specify a valid value for the MaximumExecutionFrequency
parameter.
Based on the valid value you choose, Config runs evaluations once for each valid value. For example, if you choose Three_Hours
, Config runs evaluations once every three hours. In this case, Three_Hours
is the frequency of this rule.
Provides the runtime system, policy definition, and whether debug logging is enabled. Required when owner is set to CUSTOM_POLICY
.
The runtime system for your Config Custom Policy rule. Guard is a policy-as-code language that allows you to write policies that are enforced by Config Custom Policy rules. For more information about Guard, see the Guard GitHub Repository.
The policy definition containing the logic for your Config Custom Policy rule.
The boolean expression for enabling debug logging for your Config Custom Policy rule. The default value is false
.
A string, in JSON format, that is passed to the Config rule Lambda function.
The maximum frequency with which Config runs evaluations for a rule. You can specify a value for MaximumExecutionFrequency
when:
Note
By default, rules with a periodic trigger are evaluated every 24 hours. To change the frequency, specify a valid value for the MaximumExecutionFrequency
parameter.
Indicates whether the Config rule is active or is currently being deleted by Config. It can also indicate the evaluation status for the Config rule.
Config sets the state of the rule to EVALUATING
temporarily after you use the StartConfigRulesEvaluation
request to evaluate your resources against the Config rule.
Config sets the state of the rule to DELETING_RESULTS
temporarily after you use the DeleteEvaluationResults
request to delete the current evaluation results for the Config rule.
Config temporarily sets the state of a rule to DELETING
after you use the DeleteConfigRule
request to delete the rule. After Config deletes the rule, the rule and all of its evaluations are erased and are no longer available.
Service principal name of the service that created the rule.
Note
The field is populated only if the service-linked rule is created by a service. The field is empty if you create your own rule.
The modes the Config rule can be evaluated in. The valid values are distinct objects. By default, the value is Detective evaluation mode only.
The configuration object for Config rule evaluation mode. The Supported valid values are Detective or Proactive.
The mode of an evaluation. The valid values are Detective or Proactive.
An array of tag object.
The tags for the resource. The metadata that you apply to a resource to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.
One part of a key-value pair that make up a tag. A key is a general label that acts like a category for more specific tag values.
The optional part of a key-value pair that make up a tag. A value acts as a descriptor within a tag category (key).
None
Exceptions
ConfigService.Client.exceptions.InvalidParameterValueException
ConfigService.Client.exceptions.MaxNumberOfConfigRulesExceededException
ConfigService.Client.exceptions.ResourceInUseException
ConfigService.Client.exceptions.InsufficientPermissionsException
ConfigService.Client.exceptions.NoAvailableConfigurationRecorderException