paws.management (version 0.1.0)

organizations_attach_policy: Attaches a policy to a root, an organizational unit (OU), or an individual account

Description

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:

Usage

organizations_attach_policy(PolicyId, TargetId)

Arguments

PolicyId

[required] The unique identifier (ID) of the policy that you want to attach to the target. You can get the ID for the policy by calling the ListPolicies operation.

The regex pattern for a policy ID string requires "p-" followed by from 8 to 128 lower-case letters or digits.

TargetId

[required] The unique identifier (ID) of the root, OU, or account that you want to attach the policy to. You can get the ID by calling the ListRoots, ListOrganizationalUnitsForParent, or ListAccounts operations.

The regex pattern for a target ID string requires one of the following:

  • Root: a string that begins with "r-" followed by from 4 to 32 lower-case letters or digits.

  • Account: a string that consists of exactly 12 digits.

  • Organizational unit (OU): a string that begins with "ou-" followed by from 4 to 32 lower-case letters or digits (the ID of the root that the OU is in) followed by a second "-" dash and from 8 to 32 additional lower-case letters or digits.

Request syntax

svc$attach_policy(
  PolicyId = "string",
  TargetId = "string"
)

Details

  • Service control policy (SCP) - An SCP specifies what permissions can be delegated to users in affected member accounts. The scope of influence for a policy depends on what you attach the policy to:

  • If you attach an SCP to a root, it affects all accounts in the organization.

  • If you attach an SCP to an OU, it affects all accounts in that OU and in any child OUs.

  • If you attach the policy directly to an account, then it affects only that account.

SCPs are JSON policies that specify the maximum permissions for an organization or organizational unit (OU). When you attach one SCP to a higher level root or OU, and you also attach a different SCP to a child OU or to an account, the child policy can further restrict only the permissions that pass through the parent filter and are available to the child. An SCP that is attached to a child cannot grant a permission that is not already granted by the parent. For example, imagine that the parent SCP allows permissions A, B, C, D, and E. The child SCP allows C, D, E, F, and G. The result is that the accounts affected by the child SCP are allowed to use only C, D, and E. They cannot use A or B because they were filtered out by the child OU. They also cannot use F and G because they were filtered out by the parent OU. They cannot be granted back by the child SCP; child SCPs can only filter the permissions they receive from the parent SCP.

AWS Organizations attaches a default SCP named \"FullAWSAccess to every root, OU, and account. This default SCP allows all services and actions, enabling any new child OU or account to inherit the permissions of the parent root or OU. If you detach the default policy, you must replace it with a policy that specifies the permissions that you want to allow in that OU or account.

For more information about how Organizations policies permissions work, see Using Service Control Policies in the AWS Organizations User Guide.

This operation can be called only from the organization's master account.

Examples

Run this code
# NOT RUN {
# The following example shows how to attach a service control policy (SCP)
# to an OU:
# 
# }
# NOT RUN {
svc$attach_policy(
  PolicyId = "p-examplepolicyid111",
  TargetId = "ou-examplerootid111-exampleouid111"
)
# }
# NOT RUN {
# The following example shows how to attach a service control policy (SCP)
# to an account:
# 
# }
# NOT RUN {
svc$attach_policy(
  PolicyId = "p-examplepolicyid111",
  TargetId = "333333333333"
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace