policies
Creates, updates, deletes or gets a policy resource or lists policies in a region
Overview
| Name | policies |
| Type | Resource |
| Description | Policies in AWS Organizations enable you to manage different features of the AWS accounts in your organization. You can use policies when all features are enabled in your organization. |
| Id | awscc.organizations.policies |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
name | string | Name of the Policy |
type | string | The type of policy to create. You can specify one of the following values: AISERVICES_OPT_OUT_POLICY, BACKUP_POLICY, SERVICE_CONTROL_POLICY, TAG_POLICY, CHATBOT_POLICY, RESOURCE_CONTROL_POLICY,DECLARATIVE_POLICY_EC2, SECURITYHUB_POLICY |
content | object | The Policy text content. For AWS CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. AWS CloudFormation always converts a YAML policy to JSON format before submitting it. |
description | string | Human readable description of the policy |
target_ids | array | List of unique identifiers (IDs) of the root, OU, or account that you want to attach the policy to |
tags | array | 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. |
id | string | Id of the Policy |
arn | string | ARN of the Policy |
aws_managed | boolean | A boolean value that indicates whether the specified policy is an AWS managed policy. If true, then you can attach the policy to roots, OUs, or accounts, but you cannot edit it. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
id | string | Id of the Policy |
region | string | AWS region. |
For more information, see AWS::Organizations::Policy.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | policies | INSERT | Name, Type, Content, region |
delete_resource | policies | DELETE | Identifier, region |
update_resource | policies | UPDATE | Identifier, PatchDocument, region |
list_resources | policies_list_only | SELECT | region |
get_resource | policies | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual policy.
SELECT
region,
name,
type,
content,
description,
target_ids,
tags,
id,
arn,
aws_managed
FROM awscc.organizations.policies
WHERE
region = 'us-east-1' AND
Identifier = '{{ id }}';
Lists all policies in a region.
SELECT
region,
id
FROM awscc.organizations.policies_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new policy resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.organizations.policies (
Name,
Type,
Content,
region
)
SELECT
'{{ name }}',
'{{ type }}',
'{{ content }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
/*+ create */
INSERT INTO awscc.organizations.policies (
Name,
Type,
Content,
Description,
TargetIds,
Tags,
region
)
SELECT
'{{ name }}',
'{{ type }}',
'{{ content }}',
'{{ description }}',
'{{ target_ids }}',
'{{ tags }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: policy
props:
- name: name
value: '{{ name }}'
- name: type
value: '{{ type }}'
- name: content
value: {}
- name: description
value: '{{ description }}'
- name: target_ids
value:
- '{{ target_ids[0] }}'
- name: tags
value:
- key: '{{ key }}'
value: '{{ value }}'
UPDATE example
Use the following StackQL query and manifest file to update a policy resource, using stack-deploy.
/*+ update */
UPDATE awscc.organizations.policies
SET PatchDocument = string('{{ {
"Name": name,
"Content": content,
"Description": description,
"TargetIds": target_ids,
"Tags": tags
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
DELETE example
/*+ delete */
DELETE FROM awscc.organizations.policies
WHERE
Identifier = '{{ id }}' AND
region = 'us-east-1'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
Additional Parameters
Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:
| Parameter | Description |
|---|---|
ClientToken | A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request. If you do not specify a client token, one is generated for inclusion in the request. |
RoleArn | The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.If you do not specify a role, a temporary session is created using your AWS user credentials. |
TypeVersionId | For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used. |
Permissions
To operate on the policies resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
organizations:CreatePolicy,
organizations:DescribePolicy,
organizations:AttachPolicy,
organizations:ListPolicies,
organizations:ListTagsForResource,
organizations:ListTargetsForPolicy,
organizations:TagResource
organizations:DescribePolicy,
organizations:ListTargetsForPolicy,
organizations:ListTagsForResource
organizations:AttachPolicy,
organizations:DetachPolicy,
organizations:UpdatePolicy,
organizations:ListTagsForResource,
organizations:ListTargetsForPolicy,
organizations:TagResource,
organizations:UntagResource,
organizations:DescribePolicy
organizations:DetachPolicy,
organizations:DeletePolicy
organizations:ListPolicies