attachPolicy

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:

This operation can be called only from the organization's management account or by a member account that is a delegated administrator for an Amazon Web Services service.

Samples


fun main() { 
   //sampleStart 
   // The following example shows how to attach a service control policy (SCP) to an OU
organizationsClient.attachPolicy {
    targetId = "ou-examplerootid111-exampleouid111"
    policyId = "p-examplepolicyid111"
} 
   //sampleEnd
}

fun main() { 
   //sampleStart 
   // The following example shows how to attach a service control policy (SCP) to an account
organizationsClient.attachPolicy {
    targetId = "333333333333"
    policyId = "p-examplepolicyid111"
} 
   //sampleEnd
}