PutOrganizationConfigRule - AWS Config

PutOrganizationConfigRule

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

Only a management account and a delegated administrator can create or update an organization AWS Config rule. When calling this API with a delegated administrator, you must ensure AWS Organizations ListDelegatedAdministrator permissions are added. An organization can have up to 3 delegated administrators.

This API enables organization service access through the EnableAWSServiceAccess action and creates a service-linked role AWSServiceRoleForConfigMultiAccountSetup in the management or delegated administrator account of your organization. The service-linked role is created only when the role does not exist in the caller account. AWS Config verifies the existence of role with GetRole action.

To use this API with delegated administrator, register a delegated administrator by calling AWS Organization register-delegated-administrator for config-multiaccountsetup.amazonaws.com.

There are two types of rules: AWS Config Managed Rules and AWS Config Custom Rules. You can use PutOrganizationConfigRule to create both AWS Config Managed Rules and AWS Config Custom Rules.

AWS Config Managed Rules are predefined, customizable rules created by AWS Config. For a list of managed rules, see List of AWS Config Managed Rules. If you are adding an AWS Config managed rule, you must specify the rule's identifier for the RuleIdentifier key.

AWS Config Custom Rules are rules that you create from scratch. There are two ways to create AWS Config custom rules: with Lambda functions (AWS Lambda Developer Guide) and with Guard (Guard GitHub Repository), a policy-as-code language. AWS Config custom rules created with AWS Lambda are called AWS Config Custom Lambda Rules and AWS Config custom rules created with Guard are called AWS Config Custom Policy Rules.

If you are adding a new AWS Config Custom Lambda rule, you first need to create an AWS Lambda function in the management account or a delegated administrator that the rule invokes to evaluate your resources. You also need to create an IAM role in the managed account that can be assumed by the Lambda function. When you use PutOrganizationConfigRule to add a Custom Lambda rule to AWS Config, you must specify the Amazon Resource Name (ARN) that AWS Lambda assigns to the function.

Note

Prerequisite: Ensure you call EnableAllFeatures API to enable all features in an organization.

Make sure to specify one of either OrganizationCustomPolicyRuleMetadata for Custom Policy rules, OrganizationCustomRuleMetadata for Custom Lambda rules, or OrganizationManagedRuleMetadata for managed rules.

Request Syntax

{ "ExcludedAccounts": [ "string" ], "OrganizationConfigRuleName": "string", "OrganizationCustomPolicyRuleMetadata": { "DebugLogDeliveryAccounts": [ "string" ], "Description": "string", "InputParameters": "string", "MaximumExecutionFrequency": "string", "OrganizationConfigRuleTriggerTypes": [ "string" ], "PolicyRuntime": "string", "PolicyText": "string", "ResourceIdScope": "string", "ResourceTypesScope": [ "string" ], "TagKeyScope": "string", "TagValueScope": "string" }, "OrganizationCustomRuleMetadata": { "Description": "string", "InputParameters": "string", "LambdaFunctionArn": "string", "MaximumExecutionFrequency": "string", "OrganizationConfigRuleTriggerTypes": [ "string" ], "ResourceIdScope": "string", "ResourceTypesScope": [ "string" ], "TagKeyScope": "string", "TagValueScope": "string" }, "OrganizationManagedRuleMetadata": { "Description": "string", "InputParameters": "string", "MaximumExecutionFrequency": "string", "ResourceIdScope": "string", "ResourceTypesScope": [ "string" ], "RuleIdentifier": "string", "TagKeyScope": "string", "TagValueScope": "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.

ExcludedAccounts

A comma-separated list of accounts that you want to exclude from an organization AWS Config rule.

Type: Array of strings

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

Pattern: \d{12}

Required: No

OrganizationConfigRuleName

The name that you assign to an organization AWS Config rule.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: .*\S.*

Required: Yes

OrganizationCustomPolicyRuleMetadata

An OrganizationCustomPolicyRuleMetadata object. This object specifies metadata for your organization's AWS Config Custom Policy rule. The metadata includes the runtime system in use, which accounts have debug logging enabled, and other custom rule metadata, such as resource type, resource ID of AWS resource, and organization trigger types that initiate AWS Config to evaluate AWS resources against a rule.

Type: OrganizationCustomPolicyRuleMetadata object

Required: No

OrganizationCustomRuleMetadata

An OrganizationCustomRuleMetadata object. This object specifies organization custom rule metadata such as resource type, resource ID of AWS resource, Lambda function ARN, and organization trigger types that trigger AWS Config to evaluate your AWS resources against a rule. It also provides the frequency with which you want AWS Config to run evaluations for the rule if the trigger type is periodic.

Type: OrganizationCustomRuleMetadata object

Required: No

OrganizationManagedRuleMetadata

An OrganizationManagedRuleMetadata object. This object specifies organization managed rule metadata such as resource type and ID of AWS resource along with the rule identifier. It also provides the frequency with which you want AWS Config to run evaluations for the rule if the trigger type is periodic.

Type: OrganizationManagedRuleMetadata object

Required: No

Response Syntax

{ "OrganizationConfigRuleArn": "string" }

Response Elements

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

The following data is returned in JSON format by the service.

OrganizationConfigRuleArn

The Amazon Resource Name (ARN) of an organization AWS Config rule.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

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 AWS Config lacks permissions to perform the config:Put* action.

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

  • For PutOrganizationConfigRule, organization AWS 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 not valid. Verify that your parameters are valid and try again.

HTTP Status Code: 400

MaxNumberOfOrganizationConfigRulesExceededException

You have reached the limit of the number of organization AWS Config rules you can create. For more information, see see Service Limits in the AWS Config Developer Guide.

HTTP Status Code: 400

NoAvailableOrganizationException

Organization is no longer available.

HTTP Status Code: 400

OrganizationAccessDeniedException

For PutConfigurationAggregator API, you can see this exception for the following reasons:

  • No permission to call EnableAWSServiceAccess API

  • The configuration aggregator cannot be updated because your AWS Organization management account or the delegated administrator role changed. Delete this aggregator and create a new one with the current AWS Organization.

  • The configuration aggregator is associated with a previous AWS Organization and AWS Config cannot aggregate data with current AWS Organization. Delete this aggregator and create a new one with the current AWS Organization.

  • You are not a registered delegated administrator for AWS Config with permissions to call ListDelegatedAdministrators API. Ensure that the management account registers delagated administrator for AWS Config service principle name before the delegated administrator creates an aggregator.

For all OrganizationConfigRule and OrganizationConformancePack APIs, AWS Config throws an exception if APIs are called from member accounts. All APIs must be called from organization management account.

HTTP Status Code: 400

OrganizationAllFeaturesNotEnabledException

AWS Config resource cannot be created because your organization does not have all features enabled.

HTTP Status Code: 400

ResourceInUseException

You see this exception in the following cases:

  • For DeleteConfigRule, AWS 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 AWS 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 AWS Config rule deletion is in progress. Try your request again later.

  • For DeleteOrganizationConfigRule, organization AWS 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

ValidationException

The requested action is not valid.

For PutStoredQuery, you will see this exception if there are missing required fields or if the input value fails the validation, or if you are trying to create more than 300 queries.

For GetStoredQuery, ListStoredQuery, and DeleteStoredQuery you will see this exception if there are missing required fields or if the input value fails the validation.

HTTP Status Code: 400

See Also

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