Skip to content

Latest commit

 

History

History
 
 

cloudiot

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

terraform-google-pubsub for Cloud IoT

Overview

In the early stage, this module will simply be implemented by using existing pubsub module and one resource.

This module may not improve drastically efficiency. However, after implementing new resources like terraform-provider-google#1495, this module will get more efficient by adopting the new resources.

Usage

Let's seeing a simple usage of the module. See also a simple setup provided in the example directory.

module "iot" {
  source     = "terraform-google-modules/pubsub/iot"
  name       = "sample-iot"
  region     = "us-central1"
  project_id = "tf-project"

  mqtt_enabled_state = "MQTT_ENABLED"
  http_enabled_state = "HTTP_DISABLED"

  public_key_certificates = [
    {
      format      = "X509_CERTIFICATE_PEM"
      certificate = file(var.cert_path)
    },
  ]

  event_notification_config = {
    topic              = "iot-event-topic"
    topic_labels       = {}
    create_topic       = true
    push_subscriptions = []
    pull_subscriptions = [
      {
        name                 = "iot-event-pull"
        ack_deadline_seconds = 20
      },
    ]
  }
  state_notification_config = {
    topic              = "iot-state-topic"
    topic_labels       = {}
    create_topic       = true
    push_subscriptions = []
    pull_subscriptions = [
      {
        name = "iot-state-pull"
        ack_deadline_seconds = 20
      },
    ]
  }
}

Inputs

Name Description Type Default Required
event_notification_config The event notification configuration for the Cloud IoT registry. This contains topic, topic_labels, pull_subscriptions and push_subscriptions and create_topic.
object({
topic = string
topic_labels = map(string)
push_subscriptions = list(map(string))
pull_subscriptions = list(map(string))
create_topic = bool
})
{
"create_topic": false,
"pull_subscriptions": [],
"push_subscriptions": [],
"topic": "",
"topic_labels": {}
}
no
http_enabled_state The field allows HTTP_ENABLED or HTTP_DISABLED string "HTTP_DISABLED" no
mqtt_enabled_state The field allows MQTT_ENABLED or MQTT_DISABLED string "MQTT_ENABLED" no
name The Cloud IoT registry name string n/a yes
project_id The project ID to manage the Cloud IoT resources string n/a yes
public_key_certificates The list for public key certificates list(object({ format = string, certificate = string })) [] no
region The region to host the registry string n/a yes
state_notification_config The state notification configuration for the Cloud IoT registry. This contains topic, topic_labels, pull_subscriptions and push_subscriptions and create_topic.
object({
topic = string
topic_labels = map(string)
push_subscriptions = list(map(string))
pull_subscriptions = list(map(string))
create_topic = bool
})
{
"create_topic": false,
"pull_subscriptions": [],
"push_subscriptions": [],
"topic": "",
"topic_labels": {}
}
no

Outputs

Name Description
credentials The credentials for Cloud IoT registry
event_notification_subscription_names The name list of Pub/Sub subscriptions associated with the registry
event_notification_subscription_paths The path list of Pub/Sub subscriptions associated with the registry
event_notification_topic The name of the Pub/Sub topic associated with the registry
event_notification_topic_id The id of the Pub/Sub topic associated with the registry
name The name of the Cloud IoT registry
region The region of the Cloud IoT registry
registry The registry being created by this module
state_notification_subscription_names The name list of Pub/Sub subscriptions associated with the registry
state_notification_subscription_paths The path list of Pub/Sub subscriptions associated with the registry
state_notification_topic The name of the Pub/Sub topic associated with the registry
state_notification_topic_id The id of the Pub/Sub topic associated with the registry

Requirements

Enable API

In order to operate with the service account you must activate the following API on the project where the service account was created.

  • Cloud IoT API

Configure a Service Account

In addition to the pubsub module's requirements, the following role should be attached to the service account.

  • Cloud IoT Editor