This page explains how to control access to devices using Identity and Access Management (IAM). Access can be granted at the project or registry level. There is no access control at the individual device level. Access is typically granted to a person or a group of users, or to server-side service accounts. (Devices use public/private key authentication; for more details, see the section on device security).
For example, if you assign a user the role of cloudiot.provisioner
to a device registry IAM policy, that user will be able to add or remove
devices but won't be able to modify or delete the registry itself. A role can
also be set on a cloud project; it then applies to all registries belonging to
that cloud project.
This section focuses on the IAM permissions relevant to Cloud IoT Core and the IAM roles that grant those permissions. For a detailed description of IAM and its features, see the IAM documentation. In particular, see the section on managing IAM policies.
Roles
A role is a bundle of permissions. For example,
roles/cloudiot.viewer
contains the permissions cloudiot.registries.get
,
cloudiot.registries.list
, cloudiot.devices.get
, and cloudiot.devices.list
.
You assign roles to users or groups in order to allow them to perform actions
on the registries in your project.
The following table lists the Cloud IoT Core IAM roles, including the permissions associated with each role:
Role | Description | Permissions |
---|---|---|
roles/cloudiot.viewer |
Read-only access to all Cloud IoT resources |
|
roles/cloudiot.deviceController |
Access to update the configuration of devices, but not to create or delete devices | All of the above, and:
|
roles/cloudiot.provisioner |
Access to create and delete devices from registries, but not to modify the registries | All of the above, and:
|
roles/cloudiot.editor |
Read-write access to all Cloud IoT resources | All of the above, and:
|
roles/cloudiot.admin |
Full control of all Cloud IoT resources and permissions | All of the above, and:
|
An additional role, roles/cloudiot.serviceAgent
, grants Publisher permission
for the relevant Cloud Pub/Sub topics.
This role is automatically assigned to a service account that is created when
you enable the Google Cloud IoT Core API in a project. In most cases, you won't need to set
or manage this role. If you do encounter permission errors related to
Cloud Pub/Sub topics, see Troubleshooting.
For more information about roles, see Understanding Roles.
Permissions
Permissions allow users to perform specific actions on registries or devices
in Cloud IoT Core. For example, the cloudiot.registries.list
permission allows a user to list the registries in your project. You don't
directly give users permissions; instead, you assign them roles,
which have one or more permissions bundled within them. You can also create
custom roles.
The following tables list the IAM permissions that are associated with Cloud IoT Core:
Device registry permission name | Description |
---|---|
cloudiot.registries.create |
Create a new registry in a project. |
cloudiot.registries.delete |
Delete a registry. |
cloudiot.registries.get |
Read registry details, excluding ACLs. |
cloudiot.registries.getIAMPolicy |
Read registry ACLs. |
cloudiot.registries.list |
List the registries in a project. |
cloudiot.registries.setIAMPolicy |
Update registry ACLs. |
cloudiot.registries.update |
Update registry details, excluding ACLs. |
cloudiot.devices.sendCommand |
Send commands (per registry, not per device). |
Device permission name | Description |
---|---|
cloudiot.devices.create |
Add a new device to a registry. |
cloudiot.devices.delete |
Delete a device. |
cloudiot.devices.get |
Read device details, excluding ACLs. |
cloudiot.devices.list |
List devices in a registry. |
cloudiot.devices.update |
Update device details, excluding ACLs. |
cloudiot.devices.updateConfig |
Update the device configuration. |
cloudiot.devices.bindGateway |
Bind a device to a gateway. |
cloudiot.devices.unbindGateway |
Unbind a device from a gateway. |
For details on which IAM permissions allow users to run methods on registries and devices, see each method's specific REST reference.
Cloud IoT Core IAM management
You can get and set IAM policies using Google Cloud console, the IAM API, or the gcloud tool. For information on how to do so at the project level, see Granting, Changing, and Revoking Access. The rest of this section contains information on IAM management at the device registry level.
Get a policy
Console
To get access controls for a device registry:
- Go to the Registries page in Google Cloud console.
Select the checkbox next to the device registry for which you want to set permissions. If the info panel isn't open, click Show Info Panel.
Click Permissions. A Permissions pane opens containing a list of users and their permissions.
gcloud
To get a policy for a device registry, run the gcloud iot registries get-iam-policy
command:
gcloud iot registries get-iam-policy REGISTRY_ID \ --region=REGION \ [--filter=EXPRESSION] [--limit=LIMIT] [--page-size=PAGE_SIZE] [--sort-by=[FIELD,...]]
API
To get IAM permissions via the API, use the DeviceRegistry getIamPolicy
method:
C#
Go
Java
Node.js
PHP
Python
Ruby
Set a policy
Console
To set access controls at the device registry level:
- Go to the Registries page in Google Cloud console.
Select the checkbox next to the device registry for which you want to set permissions. If the info panel isn't open, click Show Info Panel.
Click Permissions. A Permissions pane opens.
Enter a user or users, select a role from the drop-down menu, and click Add.
gcloud
To set a policy for a device registry, run the gcloud iot registries set-iam-policy
command:
gcloud iot registries set-iam-policy REGISTRY_ID \ --region=REGION \ POLICY_FILE
API
To set IAM permissions via the API, use the DeviceRegistry setIamPolicy
method: