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 }}';
/*+ create */
INSERT INTO awscc.organizations.policies (
Name,
Type,
Content,
Description,
TargetIds,
Tags,
region
)
SELECT
'{{ name }}',
'{{ type }}',
'{{ content }}',
'{{ description }}',
'{{ target_ids }}',
'{{ tags }}',
'{{ region }}';
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 }}';
DELETE example
/*+ delete */
DELETE FROM awscc.organizations.policies
WHERE
Identifier = '{{ id }}' AND
region = 'us-east-1';
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