PutConfigRule - Amazon Config
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

PutConfigRule

Adds or updates an Amazon Config rule to evaluate if your Amazon resources comply with your desired configurations. For information on how many Amazon Config rules you can have per account, see Service Limits in the Amazon Config Developer Guide.

There are two types of rules: Amazon Config Custom Rules and Amazon Config Managed Rules. You can use PutConfigRule to create both Amazon Config custom rules and Amazon 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 Amazon Config Custom Policy rules. Amazon 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 Amazon Lambda function that the rule invokes to evaluate your resources. When you use PutConfigRule to add a Custom Lambda rule to Amazon Config, you must specify the Amazon Resource Name (ARN) that Amazon 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 Amazon Config. For a list of managed rules, see List of Amazon Config Managed Rules. If you are adding an Amazon 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 Amazon 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 Amazon Config rules, see Evaluating Amazon resource Configurations with Amazon Config in the Amazon Config Developer Guide.

Request Syntax

{ "ConfigRule": { "ConfigRuleArn": "string", "ConfigRuleId": "string", "ConfigRuleName": "string", "ConfigRuleState": "string", "CreatedBy": "string", "Description": "string", "InputParameters": "string", "MaximumExecutionFrequency": "string", "Scope": { "ComplianceResourceId": "string", "ComplianceResourceTypes": [ "string" ], "TagKey": "string", "TagValue": "string" }, "Source": { "CustomPolicyDetails": { "EnableDebugLogDelivery": boolean, "PolicyRuntime": "string", "PolicyText": "string" }, "Owner": "string", "SourceDetails": [ { "EventSource": "string", "MaximumExecutionFrequency": "string", "MessageType": "string" } ], "SourceIdentifier": "string" } }, "Tags": [ { "Key": "string", "Value": "string" } ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

ConfigRule

The rule that you want to add to your account.

Type: ConfigRule object

Required: Yes

Tags

An array of tag object.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Required: No

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors.

InsufficientPermissionsException

Indicates one of the following errors:

  • For PutConfigRule, the rule cannot be created because the IAM role assigned to Amazon Config lacks permissions to perform the config:Put* action.

  • For PutConfigRule, the Amazon Lambda function cannot be invoked. Check the function ARN, and check the function's permissions.

  • For PutOrganizationConfigRule, organization Amazon Config rule cannot be created because you do not have permissions to call IAM GetRole action or create a service-linked role.

  • For PutConformancePack and PutOrganizationConformancePack, a conformance pack cannot be created because you do not have the following permissions:

    • You do not have permission to call IAM GetRole action or create a service-linked role.

    • You do not have permission to read Amazon S3 bucket or call SSM:GetDocument.

HTTP Status Code: 400

InvalidParameterValueException

One or more of the specified parameters are invalid. Verify that your parameters are valid and try again.

HTTP Status Code: 400

MaxNumberOfConfigRulesExceededException

Failed to add the Amazon Config rule because the account already contains the maximum number of 150 rules. Consider deleting any deactivated rules before you add new rules.

HTTP Status Code: 400

NoAvailableConfigurationRecorderException

There are no configuration recorders available to provide the role needed to describe your resources. Create a configuration recorder.

HTTP Status Code: 400

ResourceInUseException

You see this exception in the following cases:

  • For DeleteConfigRule, Amazon Config is deleting this rule. Try your request again later.

  • For DeleteConfigRule, the rule is deleting your evaluation results. Try your request again later.

  • For DeleteConfigRule, a remediation action is associated with the rule and Amazon Config cannot delete this rule. Delete the remediation action associated with the rule before deleting the rule and try your request again later.

  • For PutConfigOrganizationRule, organization Amazon Config rule deletion is in progress. Try your request again later.

  • For DeleteOrganizationConfigRule, organization Amazon Config rule creation is in progress. Try your request again later.

  • For PutConformancePack and PutOrganizationConformancePack, a conformance pack creation, update, and deletion is in progress. Try your request again later.

  • For DeleteConformancePack, a conformance pack creation, update, and deletion is in progress. Try your request again later.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: