Skip to main content

policies

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

Overview​

Namepolicies
TypeResource
Idovh.iam.policies

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
idstring (uuid)Unique identifier of the policy
namestringName of the policy
conditionsobjectConditions restrict permissions following resources, date or customer's information
created_atstring (date-time)Creation time (wire: createdAt)
descriptionstringDescription of the policy
expired_atstring (date-time)Expiration date of the policy, after this date it will no longer be applied (wire: expiredAt)
identitiesarrayRecipients of the delegated resources
ownerstringOwner of the policy
permissionsobjectPermissions accorded to the recipients on the given resources
permissions_groupsarrayPermissions groups accorded to the recipients on the given resources (wire: permissionsGroups)
read_onlybooleanWhether you can update policy (wire: readOnly)
resourcesarrayResources to delegate
updated_atstring (date-time)Last update time (wire: updatedAt)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectpolicy_iddetailsReturns the policy definition. Set details to true to expand resource information.
listselectx_pagination_cursor, x_pagination_size, action, details, identity, read_only, resource_urnReturns the policies of the account. Filter with identity, resourceURN and action.<br />Set readOnly to true to include the read-only policies generated by OVHcloud.<br />Set details to true to expand resource information.
createinsertidentities, name, permissions, resourcesCreates a policy that grants one or more identities access to a set of resources.<br /><br />identities are URNs: account (NIC), user (account-id/username) or group (account-id/group-name).<br />resources are resource or resourceGroup URNs.<br />Both actions and resource URNs may end with * to match several items at once.<br /><br />permissions.allow is the set of granted actions: everything else is denied by default.<br />permissions.except subtracts actions from that allow set (useful with wildcards).<br />permissions.deny forbids actions outright and always wins, including over allows from other policies.<br /><br />Optional permissionsGroups attach reusable allow/deny sets defined separately.<br />Optional conditions (AND / OR / NOT / MATCH over resource type, tags, name, request IP, date/time) must evaluate true for the policy to apply.<br />Optional expiredAt disables the policy after that date.<br /><br />A policy can target another OVHcloud account: the recipient can re-delegate only within the rights received, never beyond them.
updateupdatepolicy_id, identities, name, permissions, resourcesUpdates the policy definition: identities, resources, permissions, conditions and expiry. Omitted optional fields keep their current value.
deletedeletepolicy_idDeletes the policy and the access it granted.

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
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
policy_idstring (uuid)Policy ID (wire: policyId)
actionarrayFilter on policies embedding the given IAM action
detailsbooleanAdd extra information about resources in output
identityarrayFilter on policies embedding the given identity
read_onlybooleanFilter on the readOnly attribute (wire: readOnly)
resource_urnarrayFilter on policies embedding the given resource URN (wire: resourceURN)
x_pagination_cursorstringPagination cursor (wire: X-Pagination-Cursor)
x_pagination_sizeintegerPagination size (wire: X-Pagination-Size)

SELECT examples​

Returns the policy definition. Set details to true to expand resource information.

SELECT
id,
name,
conditions,
created_at,
description,
expired_at,
identities,
owner,
permissions,
permissions_groups,
read_only,
resources,
updated_at
FROM ovh.iam.policies
WHERE policy_id = '{{ policy_id }}' -- required
AND details = '{{ details }}'
;

INSERT examples​

Creates a policy that grants one or more identities access to a set of resources.<br /><br />identities are URNs: account (NIC), user (account-id/username) or group (account-id/group-name).<br />resources are resource or resourceGroup URNs.<br />Both actions and resource URNs may end with * to match several items at once.<br /><br />permissions.allow is the set of granted actions: everything else is denied by default.<br />permissions.except subtracts actions from that allow set (useful with wildcards).<br />permissions.deny forbids actions outright and always wins, including over allows from other policies.<br /><br />Optional permissionsGroups attach reusable allow/deny sets defined separately.<br />Optional conditions (AND / OR / NOT / MATCH over resource type, tags, name, request IP, date/time) must evaluate true for the policy to apply.<br />Optional expiredAt disables the policy after that date.<br /><br />A policy can target another OVHcloud account: the recipient can re-delegate only within the rights received, never beyond them.

INSERT INTO ovh.iam.policies (
conditions,
description,
expired_at,
identities,
name,
permissions,
permissions_groups,
resources
)
SELECT
'{{ conditions }}',
'{{ description }}',
'{{ expired_at }}',
'{{ identities }}' /* required */,
'{{ name }}' /* required */,
'{{ permissions }}' /* required */,
'{{ permissions_groups }}',
'{{ resources }}' /* required */
RETURNING
id,
name,
conditions,
created_at,
description,
expired_at,
identities,
owner,
permissions,
permissions_groups,
read_only,
resources,
updated_at
;

UPDATE examples​

Updates the policy definition: identities, resources, permissions, conditions and expiry. Omitted optional fields keep their current value.

UPDATE ovh.iam.policies
SET
conditions = '{{ conditions }}',
description = '{{ description }}',
expired_at = '{{ expired_at }}',
identities = '{{ identities }}',
name = '{{ name }}',
permissions = '{{ permissions }}',
permissions_groups = '{{ permissions_groups }}',
resources = '{{ resources }}'
WHERE
policy_id = '{{ policy_id }}' --required
AND identities = '{{ identities }}' --required
AND name = '{{ name }}' --required
AND permissions = '{{ permissions }}' --required
AND resources = '{{ resources }}' --required
RETURNING
id,
name,
conditions,
created_at,
description,
expired_at,
identities,
owner,
permissions,
permissions_groups,
read_only,
resources,
updated_at;

DELETE examples​

Deletes the policy and the access it granted.

DELETE FROM ovh.iam.policies
WHERE policy_id = '{{ policy_id }}' --required
;