Skip to main content

policy_versions

Creates, updates, deletes, gets or lists a policy_versions resource.

Overview

Namepolicy_versions
TypeResource
Idaws.iot.policy_versions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
creation_datestring (date-time)The date the policy was created.
generation_idstringThe generation ID of the policy version.
is_default_versionbooleanSpecifies whether the policy version is the default.
last_modified_datestring (date-time)The date the policy was last modified.
policy_arnstringThe policy ARN.
policy_documentstringThe JSON document that describes the policy. (pattern: <code>[\s\S]*</code>)
policy_namestringThe policy name. (pattern: <code>[\w+=,.@-]+</code>)
policy_version_idstringThe policy version ID. (pattern: <code>[0-9]+</code>)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_policy_versionselectpolicy_name, policy_version_id, regionGets information about the specified policy version. Requires permission to access the GetPolicyVersion action.
list_policy_versionsselectpolicy_name, regionLists the versions of the specified policy and identifies the default version. Requires permission to access the ListPolicyVersions action.
create_policy_versioninsertpolicy_name, region, policyDocumentsetAsDefaultCreates 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_versionupdatepolicy_name, policy_version_id, regionSets 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_versiondeletepolicy_name, policy_version_id, regionDeletes 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.

NameDatatypeDescription
policy_namestringThe name of the policy.
policy_version_idstringThe policy version ID.
regionstringAWS region (default: us-east-1)
setAsDefaultbooleanSpecifies 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

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
;

INSERT examples

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
;

UPDATE examples

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

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
;