PutOrganizationConfigRule - 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 (PDF).

PutOrganizationConfigRule

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

Only a management account and a delegated administrator can create or update an organization Amazon Config rule. When calling this API with a delegated administrator, you must ensure Amazon 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. Amazon Config verifies the existence of role with GetRole action.

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

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

Amazon Config 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 RuleIdentifier key.

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

If you are adding a new Amazon Config Custom Lambda rule, you first need to create an Amazon 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 Amazon Config, you must specify the Amazon Resource Name (ARN) that Amazon 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 Amazon 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 Amazon 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 Amazon 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 Amazon resource, and organization trigger types that initiate Amazon Config to evaluate Amazon 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 Amazon resource, Lambda function ARN, and organization trigger types that trigger Amazon Config to evaluate your Amazon resources against a rule. It also provides the frequency with which you want Amazon 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 Amazon resource along with the rule identifier. It also provides the frequency with which you want Amazon 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 Amazon 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 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 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 Amazon Config rules you can create. For more information, see see Service Limits in the Amazon 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 Amazon Organization management account or the delegated administrator role changed. Delete this aggregator and create a new one with the current Amazon Organization.

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

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

For all OrganizationConfigRule and OrganizationConformancePack APIs, Amazon 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

Amazon 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, 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

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 Amazon SDKs, see the following: