googleCloudiotDevice
A Google Cloud IoT Core device.
To get more information about Device, see:
- API documentation
- How-to Guides
- Official Documentation
Example Usage - Cloudiot Device Basic
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleCloudiotRegistryRegistry =
new google.cloudiotRegistry.CloudiotRegistry(this, "registry", {
name: "cloudiot-device-registry",
});
new google.cloudiotDevice.CloudiotDevice(this, "test-device", {
name: "cloudiot-device",
registry: googleCloudiotRegistryRegistry.id,
});
Example Usage - Cloudiot Device Full
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleCloudiotRegistryRegistry =
new google.cloudiotRegistry.CloudiotRegistry(this, "registry", {
name: "cloudiot-device-registry",
});
new google.cloudiotDevice.CloudiotDevice(this, "test-device", {
blocked: false,
credentials: [
{
public_key: [
{
format: "RSA_PEM",
key: '${file("test-fixtures/rsa_public.pem")}',
},
],
},
],
gateway_config: [
{
gateway_type: "NON_GATEWAY",
},
],
log_level: "INFO",
metadata: [
{
test_key_1: "test_value_1",
},
],
name: "cloudiot-device",
registry: googleCloudiotRegistryRegistry.id,
});
Argument Reference
The following arguments are supported:
-
name
- (Required) A unique name for the resource. -
registry
- (Required) The name of the device registry where this device should be created.
-
credentials
- (Optional) The credentials used to authenticate this device. Structure is documented below. -
blocked
- (Optional) If a device is blocked, connections or requests from this device will fail. -
logLevel
- (Optional) The logging verbosity for device activity. Possible values arenone
,error
,info
, anddebug
. -
metadata
- (Optional) The metadata key-value pairs assigned to the device. -
gatewayConfig
- (Optional) Gateway-related configuration and state. Structure is documented below.
The credentials
block supports:
-
expirationTime
- (Optional) The time at which this credential becomes invalid. -
publicKey
- (Required) A public key used to verify the signature of JSON Web Tokens (JWTs). Structure is documented below.
-
format
- (Required) The format of the key. Possible values arersaPem
,rsaX509Pem
,es256Pem
, andes256X509Pem
. -
key
- (Required) The key data.
The gatewayConfig
block supports:
-
gatewayType
- (Optional) Indicates whether the device is a gateway. Default value isnonGateway
. Possible values aregateway
andnonGateway
. -
gatewayAuthMethod
- (Optional) Indicates whether the device is a gateway. Possible values areassociationOnly
,deviceAuthTokenOnly
, andassociationAndDeviceAuthToken
. -
lastAccessedGatewayId
- (Output) The ID of the gateway the device accessed most recently. -
lastAccessedGatewayTime
- (Output) The most recent time at which the device accessed the gateway specified in last_accessed_gateway.
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
-
id
- an identifier for the resource with format{{registry}}/devices/{{name}}
-
numId
- A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique. -
lastHeartbeatTime
- The last time an MQTT PINGREQ was received. -
lastEventTime
- The last time a telemetry event was received. -
lastStateTime
- The last time a state event was received. -
lastConfigAckTime
- The last time a cloud-to-device config version acknowledgment was received from the device. -
lastConfigSendTime
- The last time a cloud-to-device config version was sent to the device. -
lastErrorTime
- The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. -
lastErrorStatus
- The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. Structure is documented below. -
config
- The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. Structure is documented below. -
state
- The state most recently received from the device. Structure is documented below.
The lastErrorStatus
block contains:
-
number
- (Optional) The status code, which should be an enum value of google.rpc.Code. -
message
- (Optional) A developer-facing error message, which should be in English. -
details
- (Optional) A list of messages that carry the error details.
-
version
- (Output) The version of this update. -
cloudUpdateTime
- (Output) The time at which this configuration version was updated in Cloud IoT Core. -
deviceAckTime
- (Output) The time at which Cloud IoT Core received the acknowledgment from the device, indicating that the device has received this configuration version. -
binaryData
- (Optional) The device configuration data.
-
updateTime
- (Optional) The time at which this state version was updated in Cloud IoT Core. -
binaryData
- (Optional) The device state data.
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.
Import
Device can be imported using any of these accepted formats: