policy_versions
Creates, updates, deletes, gets or lists a policy_versions resource.
Overview
| Name | policy_versions |
| Type | Resource |
| Id | aws.iot.policy_versions |
Fields
The following fields are returned by SELECT queries:
- get_policy_version
- list_policy_versions
| Name | Datatype | Description |
|---|---|---|
creation_date | string (date-time) | The date the policy was created. |
generation_id | string | The generation ID of the policy version. |
is_default_version | boolean | Specifies whether the policy version is the default. |
last_modified_date | string (date-time) | The date the policy was last modified. |
policy_arn | string | The policy ARN. |
policy_document | string | The JSON document that describes the policy. (pattern: <code>[\s\S]*</code>) |
policy_name | string | The policy name. (pattern: <code>[\w+=,.@-]+</code>) |
policy_version_id | string | The policy version ID. (pattern: <code>[0-9]+</code>) |
| Name | Datatype | Description |
|---|---|---|
policy_versions | array | The policy versions. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_policy_version | select | policy_name, policy_version_id, region | Gets information about the specified policy version. Requires permission to access the GetPolicyVersion action. | |
list_policy_versions | select | policy_name, region | Lists the versions of the specified policy and identifies the default version. Requires permission to access the ListPolicyVersions action. | |
create_policy_version | insert | policy_name, region, policyDocument | setAsDefault | Creates a new version of the specified IoT policy. To update a policy, create a new policy version. A managed policy can have up to five versions. If the policy has five versions, you must use DeletePolicyVersion to delete an existing version before you create a new one. Optionally, you can set the new version as the policy's default version. The default version is the operative version (that is, the version that is in effect for the certificates to which the policy is attached). Requires permission to access the CreatePolicyVersion action. |
set_default_policy_version | update | policy_name, policy_version_id, region | Sets the specified version of the specified policy as the policy's default (operative) version. This action affects all certificates to which the policy is attached. To list the principals the policy is attached to, use the ListPrincipalPolicies action. Requires permission to access the SetDefaultPolicyVersion action. | |
delete_policy_version | delete | policy_name, policy_version_id, region | Deletes the specified version of the specified policy. You cannot delete the default version of a policy using this action. To delete the default version of a policy, use DeletePolicy. To find out which version of a policy is marked as the default version, use ListPolicyVersions. Requires permission to access the DeletePolicyVersion action. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
policy_name | string | The name of the policy. |
policy_version_id | string | The policy version ID. |
region | string | AWS region (default: us-east-1) |
setAsDefault | boolean | Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version (that is, the version that is in effect for the certificates to which the policy is attached). |
SELECT examples
- get_policy_version
- list_policy_versions
Gets information about the specified policy version. Requires permission to access the GetPolicyVersion action.
SELECT
creation_date,
generation_id,
is_default_version,
last_modified_date,
policy_arn,
policy_document,
policy_name,
policy_version_id
FROM aws.iot.policy_versions
WHERE policy_name = '{{ policy_name }}' -- required
AND policy_version_id = '{{ policy_version_id }}' -- required
AND region = '{{ region }}' -- required
;
Lists the versions of the specified policy and identifies the default version. Requires permission to access the ListPolicyVersions action.
SELECT
policy_versions
FROM aws.iot.policy_versions
WHERE policy_name = '{{ policy_name }}' -- required
AND region = '{{ region }}' -- required
;
INSERT examples
- create_policy_version
- Manifest
Creates a new version of the specified IoT policy. To update a policy, create a new policy version. A managed policy can have up to five versions. If the policy has five versions, you must use DeletePolicyVersion to delete an existing version before you create a new one. Optionally, you can set the new version as the policy's default version. The default version is the operative version (that is, the version that is in effect for the certificates to which the policy is attached). Requires permission to access the CreatePolicyVersion action.
INSERT INTO aws.iot.policy_versions (
policyDocument,
policy_name,
region,
setAsDefault
)
SELECT
'{{ policyDocument }}' /* required */,
'{{ policy_name }}',
'{{ region }}',
'{{ setAsDefault }}'
RETURNING
is_default_version,
policy_arn,
policy_document,
policy_version_id
;
# Description fields are for documentation purposes
- name: policy_versions
props:
- name: policy_name
value: "{{ policy_name }}"
description: Required parameter for the policy_versions resource.
- name: region
value: "{{ region }}"
description: Required parameter for the policy_versions resource.
- name: policyDocument
value: "{{ policyDocument }}"
- name: setAsDefault
value: {{ setAsDefault }}
description: Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version (that is, the version that is in effect for the certificates to which the policy is attached).
description: Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version (that is, the version that is in effect for the certificates to which the policy is attached).
UPDATE examples
- set_default_policy_version
Sets the specified version of the specified policy as the policy's default (operative) version. This action affects all certificates to which the policy is attached. To list the principals the policy is attached to, use the ListPrincipalPolicies action. Requires permission to access the SetDefaultPolicyVersion action.
UPDATE aws.iot.policy_versions
SET
-- No updatable properties
WHERE
policy_name = '{{ policy_name }}' --required
AND policy_version_id = '{{ policy_version_id }}' --required
AND region = '{{ region }}' --required;
DELETE examples
- delete_policy_version
Deletes the specified version of the specified policy. You cannot delete the default version of a policy using this action. To delete the default version of a policy, use DeletePolicy. To find out which version of a policy is marked as the default version, use ListPolicyVersions. Requires permission to access the DeletePolicyVersion action.
DELETE FROM aws.iot.policy_versions
WHERE policy_name = '{{ policy_name }}' --required
AND policy_version_id = '{{ policy_version_id }}' --required
AND region = '{{ region }}' --required
;