Skip to main content

policies

Creates, updates, deletes, gets or lists a policies resource.

Overview

Namepolicies
TypeResource
Idaws.organizations.policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
contentstringThe text content of the policy. (pattern: <code>[\s\S]*</code>)
policy_summaryobjectA structure that contains additional details about the policy.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_policyselectregionRetrieves information about a policy. You can only call this operation from the management account or a member account that is a delegated administrator.
list_policiesselectregionRetrieves the list of all policies in an organization of a specified type. When calling List* operations, always check the NextToken response parameter value, even if you receive an empty result set. These operations can occasionally return an empty set of results even when more results are available. Continue making requests until NextToken returns null. A null NextToken value indicates that you have retrieved all available results. You can only call this operation from the management account or a member account that is a delegated administrator.
create_policyinsertregion, ContentCreates a policy of a specified type that you can attach to a root, an organizational unit (OU), or an individual Amazon Web Services account. For more information about policies and their use, see Managing Organizations policies. If the request includes tags, then the requester must have the organizations:TagResource permission. You can only call this operation from the management account or a member account that is a delegated administrator.
attach_policyupdateregion, PolicyId, TargetIdAttaches a policy to a root, an organizational unit (OU), or an individual account. How the policy affects accounts depends on the type of policy. Refer to the Organizations User Guide for information about each policy type: SERVICE_CONTROL_POLICY RESOURCE_CONTROL_POLICY DECLARATIVE_POLICY_EC2 BACKUP_POLICY TAG_POLICY CHATBOT_POLICY AISERVICES_OPT_OUT_POLICY SECURITYHUB_POLICY UPGRADE_ROLLOUT_POLICY INSPECTOR_POLICY BEDROCK_POLICY S3_POLICY NETWORK_SECURITY_DIRECTOR_POLICY You can only call this operation from the management account or a member account that is a delegated administrator.
update_policyupdateregion, PolicyIdUpdates an existing policy with a new name, description, or content. If you don't supply any parameter, that value remains unchanged. You can't change a policy's type. You can only call this operation from the management account or a member account that is a delegated administrator.
delete_policydeleteregionDeletes the specified policy from your organization. Before you perform this operation, you must first detach the policy from all organizational units (OUs), roots, and accounts. You can only call this operation from the management account or a member account that is a delegated administrator.
detach_policyexecregion, PolicyId, TargetIdDetaches a policy from a target root, organizational unit (OU), or account. If the policy being detached is a service control policy (SCP), the changes to permissions for Identity and Access Management (IAM) users and roles in affected accounts are immediate. Every root, OU, and account must have at least one SCP attached. If you want to replace the default FullAWSAccess policy with an SCP that limits the permissions that can be delegated, you must attach the replacement SCP before you can remove the default SCP. This is the authorization strategy of an "allow list". If you instead attach a second SCP and leave the FullAWSAccess SCP still attached, and specify "Effect": "Deny" in the second SCP to override the "Effect": "Allow" in the FullAWSAccess policy (or any other attached SCP), you're using the authorization strategy of a "deny list". You can only call this operation from the management account or a member account that is a delegated administrator.
disable_policy_typeexecregion, RootId, PolicyTypeDisables an organizational policy type in a root. A policy of a certain type can be attached to entities in a root only if that type is enabled in the root. After you perform this operation, you no longer can attach policies of the specified type to that root or to any organizational unit (OU) or account in that root. You can undo this by using the EnablePolicyType operation. This is an asynchronous request that Amazon Web Services performs in the background. If you disable a policy type for a root, it still appears enabled for the organization if all features are enabled for the organization. Amazon Web Services recommends that you first use ListRoots to see the status of policy types for a specified root, and then use this operation. You can only call this operation from the management account or a member account that is a delegated administrator. To view the status of available policy types in the organization, use ListRoots.
enable_policy_typeexecregion, RootId, PolicyTypeEnables a policy type in a root. After you enable a policy type in a root, you can attach policies of that type to the root, any organizational unit (OU), or account in that root. You can undo this by using the DisablePolicyType operation. This is an asynchronous request that Amazon Web Services performs in the background. Amazon Web Services recommends that you first use ListRoots to see the status of policy types for a specified root, and then use this operation. You can only call this operation from the management account or a member account that is a delegated administrator. You can enable a policy type in a root only if that policy type is available in the organization. To view the status of available policy types in the organization, use ListRoots.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Retrieves information about a policy. You can only call this operation from the management account or a member account that is a delegated administrator.

SELECT
content,
policy_summary
FROM aws.organizations.policies
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates a policy of a specified type that you can attach to a root, an organizational unit (OU), or an individual Amazon Web Services account. For more information about policies and their use, see Managing Organizations policies. If the request includes tags, then the requester must have the organizations:TagResource permission. You can only call this operation from the management account or a member account that is a delegated administrator.

INSERT INTO aws.organizations.policies (
Content,
Description,
Name,
Type,
Tags,
region
)
SELECT
'{{ Content }}' /* required */,
'{{ Description }}',
'{{ Name }}',
'{{ Type }}',
'{{ Tags }}',
'{{ region }}'
RETURNING
policy
;

UPDATE examples

Attaches a policy to a root, an organizational unit (OU), or an individual account. How the policy affects accounts depends on the type of policy. Refer to the Organizations User Guide for information about each policy type: SERVICE_CONTROL_POLICY RESOURCE_CONTROL_POLICY DECLARATIVE_POLICY_EC2 BACKUP_POLICY TAG_POLICY CHATBOT_POLICY AISERVICES_OPT_OUT_POLICY SECURITYHUB_POLICY UPGRADE_ROLLOUT_POLICY INSPECTOR_POLICY BEDROCK_POLICY S3_POLICY NETWORK_SECURITY_DIRECTOR_POLICY You can only call this operation from the management account or a member account that is a delegated administrator.

UPDATE aws.organizations.policies
SET
PolicyId = '{{ PolicyId }}',
TargetId = '{{ TargetId }}'
WHERE
region = '{{ region }}' --required
AND PolicyId = '{{ PolicyId }}' --required
AND TargetId = '{{ TargetId }}' --required;

DELETE examples

Deletes the specified policy from your organization. Before you perform this operation, you must first detach the policy from all organizational units (OUs), roots, and accounts. You can only call this operation from the management account or a member account that is a delegated administrator.

DELETE FROM aws.organizations.policies
WHERE region = '{{ region }}' --required
;

Lifecycle Methods

Detaches a policy from a target root, organizational unit (OU), or account. If the policy being detached is a service control policy (SCP), the changes to permissions for Identity and Access Management (IAM) users and roles in affected accounts are immediate. Every root, OU, and account must have at least one SCP attached. If you want to replace the default FullAWSAccess policy with an SCP that limits the permissions that can be delegated, you must attach the replacement SCP before you can remove the default SCP. This is the authorization strategy of an "allow list". If you instead attach a second SCP and leave the FullAWSAccess SCP still attached, and specify "Effect": "Deny" in the second SCP to override the "Effect": "Allow" in the FullAWSAccess policy (or any other attached SCP), you're using the authorization strategy of a "deny list". You can only call this operation from the management account or a member account that is a delegated administrator.

EXEC aws.organizations.policies.detach_policy
@region='{{ region }}' --required
@@json=
'{
"PolicyId": "{{ PolicyId }}",
"TargetId": "{{ TargetId }}"
}'
;