createPolicy

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.

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 create a service control policy (SCP) that is named
// AllowAllS3Actions. The JSON string in the content parameter specifies the content in the policy. The parameter string
// is escaped with backslashes to ensure that the embedded double quotes in the JSON policy are treated
// as literals in the parameter, which itself is surrounded by double quotes
val resp = organizationsClient.createPolicy {
    content = "{\\\"Version\\\":\\\"2012-10-17\\\",\\\"Statement\\\":{\\\"Effect\\\":\\\"Allow\\\",\\\"Action\\\":\\\"s3:*\\\"}}"
    type = PolicyType.fromValue("SERVICE_CONTROL_POLICY")
    description = "Enables admins of attached accounts to delegate all S3 permissions"
    name = "AllowAllS3Actions"
} 
   //sampleEnd
}