A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/organizations/latest/APIReference/API_CreatePolicy.html below:

CreatePolicy - AWS Organizations

CreatePolicy

Creates a policy of a specified type that you can attach to a root, an organizational unit (OU), or an individual AWS account.

For more information about policies and their use, see Managing AWS 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.

Request Syntax
{
   "Content": "string",
   "Description": "string",
   "Name": "string",
   "Tags": [ 
      { 
         "Key": "string",
         "Value": "string"
      }
   ],
   "Type": "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.

Content

The policy text content to add to the new policy. The text that you supply must adhere to the rules of the policy type you specify in the Type parameter.

The maximum size of a policy document depends on the policy's type. For more information, see Maximum and minimum values in the AWS Organizations User Guide.

Type: String

Length Constraints: Minimum length of 1.

Pattern: [\s\S]*

Required: Yes

Description

An optional description to assign to the policy.

Type: String

Length Constraints: Maximum length of 512.

Pattern: [\s\S]*

Required: Yes

Name

The friendly name to assign to the policy.

The regex pattern that is used to validate this parameter is a string of any of the characters in the ASCII character range.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\s\S]*

Required: Yes

Tags

A list of tags that you want to attach to the newly created policy. For each tag in the list, you must specify both a tag key and a value. You can set the value to an empty string, but you can't set it to null. For more information about tagging, see Tagging AWS Organizations resources in the AWS Organizations User Guide.

Note

If any one of the tags is not valid or if you exceed the allowed number of tags for a policy, then the entire request fails and the policy is not created.

Type: Array of Tag objects

Required: No

Type

The type of policy to create. You can specify one of the following values:

Type: String

Valid Values: SERVICE_CONTROL_POLICY | RESOURCE_CONTROL_POLICY | TAG_POLICY | BACKUP_POLICY | AISERVICES_OPT_OUT_POLICY | CHATBOT_POLICY | DECLARATIVE_POLICY_EC2 | SECURITYHUB_POLICY

Required: Yes

Response Syntax
{
   "Policy": { 
      "Content": "string",
      "PolicySummary": { 
         "Arn": "string",
         "AwsManaged": boolean,
         "Description": "string",
         "Id": "string",
         "Name": "string",
         "Type": "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.

Policy

A structure that contains details about the newly created policy.

Type: Policy object

Errors

For information about the errors that are common to all actions, see Common Errors.

AccessDeniedException

You don't have permissions to perform the requested operation. The user or role that is making the request must have at least one IAM permissions policy attached that grants the required permissions. For more information, see Access Management in the IAM User Guide.

HTTP Status Code: 400

AWSOrganizationsNotInUseException

Your account isn't a member of an organization. To make this request, you must use the credentials of an account that belongs to an organization.

HTTP Status Code: 400

ConcurrentModificationException

The target of the operation is currently being modified by a different request. Try again later.

HTTP Status Code: 400

ConstraintViolationException

Performing this operation violates a minimum or maximum value limit. For example, attempting to remove the last service control policy (SCP) from an OU or root, inviting or creating too many accounts to the organization, or attaching too many policies to an account, OU, or root. This exception includes a reason that contains additional information about the violated limit:

Note

Some of the reasons in the following list might not be applicable to this specific API or operation.

HTTP Status Code: 400

DuplicatePolicyException

A policy with the same name already exists.

HTTP Status Code: 400

InvalidInputException

The requested operation failed because you provided invalid values for one or more of the request parameters. This exception includes a reason that contains additional information about the violated limit:

Note

Some of the reasons in the following list might not be applicable to this specific API or operation.

HTTP Status Code: 400

MalformedPolicyDocumentException

The provided policy document doesn't meet the requirements of the specified policy type. For example, the syntax might be incorrect. For details about service control policy syntax, see SCP syntax in the AWS Organizations User Guide.

HTTP Status Code: 400

PolicyTypeNotAvailableForOrganizationException

You can't use the specified policy type with the feature set currently enabled for this organization. For example, you can enable SCPs only after you enable all features in the organization. For more information, see Managing AWS Organizations policiesin the AWS Organizations User Guide.

HTTP Status Code: 400

ServiceException

AWS Organizations can't complete your request because of an internal service error. Try again later.

HTTP Status Code: 500

TooManyRequestsException

You have sent too many requests in too short a period of time. The quota helps protect against denial-of-service attacks. Try again later.

For information about quotas that affect AWS Organizations, see Quotas for AWS Organizations in the AWS Organizations User Guide.

HTTP Status Code: 400

UnsupportedAPIEndpointException

This action isn't available in the current AWS Region.

HTTP Status Code: 400

Examples Example

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. This helps ensure that the embedded double quotation marks in the JSON policy are treated as literals in the parameter, which itself is surrounded by double quotation marks.

Sample Request
POST / HTTP/1.1
X-Amz-Target: AWSOrganizationsV20161128.CreatePolicy

{ "Content": "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"s3:*\"}}", 
  "Type": "SERVICE_CONTROL_POLICY", 
  "Description": "Enables admins of attached accounts to delegate all S3 permissions", 
  "Name": "AllowAllS3Actions" }
Sample Response
HTTP/1.1 200 OK
Content-Type: application/json
{
  "Policy": {
    "Content": "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"s3:*\"}}",
    "PolicySummary": {
      "Arn": "arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111",
      "Description": "Allows delegation of all S3 actions",
      "Name": "AllowAllS3Actions",
      "Type":"SERVICE_CONTROL_POLICY"
    }
  }
}
Example

The following example shows how to create a resource control policy (RCP) that is named EnforceSSL. The JSON string in the content parameter specifies the content in the policy. The parameter string is escaped with backslashes. This helps ensure that the embedded double quotation marks in the JSON policy are treated as literals in the parameter, which itself is surrounded by double quotation marks.

Sample Request
POST / HTTP/1.1
X-Amz-Target: AWSOrganizationsV20161128.CreatePolicy

{  "Content": " {\"Version\":\"2012-10-
17\",\"Statement\":{\"Effect\":\"Deny\",\"Principal\":\"*\","Action\":\"*\",\"Resource\":
\"*\,"Condition\":{\"BoolIfExists\":{\"aws:SecureTransport\":\"false\"}}",
 "Description": "Requires that access to all resources are sent using SSL",
 "Name": "EnforceSSL",
 "Type": "RESOURCE_CONTROL_POLICY"
}
Sample Response
"HTTP/1.1 200 OK
Content-Type":"application/json"{
   "Policy":{
      "Content":" {\"Version\":\"2012-10-
17\",\"Statement\":{\"Effect\":\"Deny\",\"Principal\":\"*\",""Action\\"":\"*\",\"Resource\":
\"*\\,""Condition\\"":{\"BoolIfExists\":{\"aws:SecureTransport\":\"false\"}}",
      "PolicySummary":{
         "Arn":"arn:aws:organizations::111111111111:policy/oexampleorgid/resource_control_policy/p-examplepolicyid111",
         "Description":"Requires that access to all resources are sent using SSL",
         "Name":"EnforceSSL",
         "Type":"RESOURCE_CONTROL_POLICY"
      }
   }
}
See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4