Attach an IAM role to a group on Vultr. All members of the group inherit the permissions from the role's attached policies through the Vultr IAM system.
Attaching a role to a group grants all members of the group the permissions defined by the policies within that role. This simplifies access management by allowing you to control permissions at the group level.
Follow this guide to attach a role to a group using the Vultr Console, the Vultr API, or Terraform.
Log in to the Vultr Console.
Click the organization name in the top navigation bar.
Click Manage Organization.
Click the Groups tab.
Click the name of the group to which you want to attach the role.
In the Roles section, click the + button.
Search and select the roles you want to attach.
Click Add Selected.
The selected roles appear in the Roles section and all group members inherit the associated permissions.
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 you want to attach.
Send a GET request to the List Groups endpoint to retrieve all groups.
$ curl "https://api.vultr.com/v2/groups" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Note the id of the group to which you want to attach the role.
Send a POST request to the Attach Role to Group endpoint to attach the role. Replace {role-id} with the role id and {group-id} with the group id.
$ curl "https://api.vultr.com/v2/roles/{role-id}/groups/{group-id}" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}"
A successful request returns an HTTP 201 Created response.
type = "assignable" can be attached to groups. Assumable roles cannot be attached to groups.
Ensure the Vultr Terraform provider is configured in your Terraform project.
Define the role-group attachment resource. Use Terraform references if the role and group are managed in the same configuration, or replace with literal IDs.
resource "vultr_organization_role_group_attachment" "role-group-attachment" {
role_id = vultr_organization_role.my_role.id
group_id = vultr_organization_group.my_group.id
}
Apply the configuration.
$ terraform apply
Verify that the output shows vultr_organization_role_group_attachment.role-group-attachment: Creation complete.