Attach an IAM policy to a role on Vultr. Add permission rules to the role that are inherited by all users and groups assigned to it through the IAM system.
Attaching a policy to a role adds the policy's permission rules to the role. All users and groups assigned to the role automatically inherit the permissions defined in the attached policy.
This guide explains how to attach a policy to a role using the Vultr Console and the Vultr API.
Log in to the Vultr Console.
Click the organization name in the top navigation bar.
Click Manage Organization.
Click the Roles tab.
Click the name of the role to which you want to attach a policy.
In the Permission Policies section, click the + button.
Search for and select the policies you want to attach.
Click Add Permission Policies.
The selected policies appear in the Permission Policies section.
Send a GET request to the List Roles endpoint to retrieve all roles in your organization.
$ curl "https://api.vultr.com/v2/roles" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Note the id of the role to which you want to attach a policy.
Send a GET request to the List Policies endpoint to retrieve all available policies.
$ curl "https://api.vultr.com/v2/policies" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Note the id of the policy you want to attach.
Send a POST request to the Attach Policy to Role endpoint to attach the policy. Replace {role-id} with the role id and {policy-id} with the policy id.
$ curl "https://api.vultr.com/v2/roles/{role-id}/policies/{policy-id}" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}"
A successful request returns an HTTP 201 Created response.