Skip to main content

policies

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

Overview​

Namepolicies
TypeResource
Idaws.iot.policies

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
creation_datestring (date-time)The date the policy was created.
default_version_idstringThe default policy version ID. (pattern: <code>[0-9]+</code>)
generation_idstringThe generation ID of the policy.
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>)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_policyselectpolicy_name, regionGets information about the specified policy with the policy document of the default version. Requires permission to access the GetPolicy action.
list_policiesselectregionmarker, pageSize, isAscendingOrderLists your policies. Requires permission to access the ListPolicies action.
create_policyinsertpolicy_name, region, policyDocumentCreates an IoT policy. The created policy is the default version for the policy. This operation creates a policy version with a version identifier of 1 and sets 1 as the policy's default version. Requires permission to access the CreatePolicy action.
attach_policyupdatepolicy_name, region, targetAttaches the specified policy to the specified principal (certificate or other credential). Requires permission to access the AttachPolicy action.
delete_policydeletepolicy_name, regionDeletes the specified policy. A policy cannot be deleted if it has non-default versions or it is attached to any certificate. To delete a policy, use the DeletePolicyVersion action to delete all non-default versions of the policy; use the DetachPolicy action to detach the policy from any certificate; and then use the DeletePolicy action to delete the policy. When a policy is deleted using DeletePolicy, its default version is deleted with it. Because of the distributed nature of Amazon Web Services, it can take up to five minutes after a policy is detached before it's ready to be deleted. Requires permission to access the DeletePolicy action.
detach_policyexecpolicy_name, region, targetDetaches a policy from the specified target. Because of the distributed nature of Amazon Web Services, it can take up to five minutes after a policy is detached before it's ready to be deleted. Requires permission to access the DetachPolicy 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 policy to detach.
regionstringAWS region (default: us-east-1)
isAscendingOrderbooleanSpecifies the order for results. If true, the results are returned in ascending creation order.
markerstringThe marker for the next set of results.
pageSizeintegerThe result page size.

SELECT examples​

Gets information about the specified policy with the policy document of the default version. Requires permission to access the GetPolicy action.

SELECT
creation_date,
default_version_id,
generation_id,
last_modified_date,
policy_arn,
policy_document,
policy_name
FROM aws.iot.policies
WHERE policy_name = '{{ policy_name }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples​

Creates an IoT policy. The created policy is the default version for the policy. This operation creates a policy version with a version identifier of 1 and sets 1 as the policy's default version. Requires permission to access the CreatePolicy action.

INSERT INTO aws.iot.policies (
policyDocument,
tags,
policy_name,
region
)
SELECT
'{{ policyDocument }}' /* required */,
'{{ tags }}',
'{{ policy_name }}',
'{{ region }}'
RETURNING
policy_arn,
policy_document,
policy_name,
policy_version_id
;

UPDATE examples​

Attaches the specified policy to the specified principal (certificate or other credential). Requires permission to access the AttachPolicy action.

UPDATE aws.iot.policies
SET
target = '{{ target }}'
WHERE
policy_name = '{{ policy_name }}' --required
AND region = '{{ region }}' --required
AND target = '{{ target }}' --required;

DELETE examples​

Deletes the specified policy. A policy cannot be deleted if it has non-default versions or it is attached to any certificate. To delete a policy, use the DeletePolicyVersion action to delete all non-default versions of the policy; use the DetachPolicy action to detach the policy from any certificate; and then use the DeletePolicy action to delete the policy. When a policy is deleted using DeletePolicy, its default version is deleted with it. Because of the distributed nature of Amazon Web Services, it can take up to five minutes after a policy is detached before it's ready to be deleted. Requires permission to access the DeletePolicy action.

DELETE FROM aws.iot.policies
WHERE policy_name = '{{ policy_name }}' --required
AND region = '{{ region }}' --required
;

Lifecycle Methods​

Detaches a policy from the specified target. Because of the distributed nature of Amazon Web Services, it can take up to five minutes after a policy is detached before it's ready to be deleted. Requires permission to access the DetachPolicy action.

EXEC aws.iot.policies.detach_policy
@policy_name='{{ policy_name }}' --required,
@region='{{ region }}' --required
@@json=
'{
"target": "{{ target }}"
}'
;