diff --git a/examples/cloudiot/README.md b/examples/cloudiot/README.md deleted file mode 100644 index 6fb526e..0000000 --- a/examples/cloudiot/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Cloud IoT Example - - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| project\_id | The project ID to manage the Pub/Sub resources | `string` | n/a | yes | - -## Outputs - -| Name | Description | -|------|-------------| -| project\_id | The project ID | -| region | The region for the IoT resources | -| registry\_name | The name of the Pub/Sub topic created | - - - -## Requirements - -The following sections describe the requirements which must be met in -order to invoke this example. The requirements of the -[cloudiot module](../../modules/cloudiot) must be met. - -## Usage - -To provision this example, populate `terraform.tfvars` with the [required variables](#inputs) and run the following commands within -this directory: -- `terraform init` to get the plugins -- `terraform plan` to see the infrastructure plan -- `terraform apply` to apply the infrastructure build -- `terraform destroy` to destroy the built infrastructure diff --git a/examples/cloudiot/main.tf b/examples/cloudiot/main.tf deleted file mode 100644 index b8365a3..0000000 --- a/examples/cloudiot/main.tf +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -provider "google" { - region = "us-central1" -} - -resource "tls_private_key" "private_keys" { - count = 2 - algorithm = "RSA" -} - -resource "tls_self_signed_cert" "certs" { - count = 2 - private_key_pem = tls_private_key.private_keys[count.index].private_key_pem - subject { - common_name = "example.com" - organization = "ACME Examples, Inc" - } - validity_period_hours = 12 - allowed_uses = [] -} - -module "iot" { - source = "../../modules/cloudiot" - name = "cft-ci-iot-registry" - region = "us-central1" - project_id = var.project_id - mqtt_enabled_state = "MQTT_ENABLED" - http_enabled_state = "HTTP_DISABLED" - public_key_certificates = [ - { - format = "X509_CERTIFICATE_PEM" - certificate = tls_self_signed_cert.certs[0].cert_pem - }, - { - format = "X509_CERTIFICATE_PEM" - certificate = tls_self_signed_cert.certs[1].cert_pem - }, - ] - event_notification_config = { - topic = "cft-ci-iot-registry-event-topic" - topic_labels = {} - create_topic = true - push_subscriptions = [] - pull_subscriptions = [ - { - name = "cft-ci-iot-registry-event-pull" - ack_deadline_seconds = 20 - } - ] - } - state_notification_config = { - topic = "cft-ci-iot-registry-state-topic" - topic_labels = {} - create_topic = true - push_subscriptions = [ - { - name = "cft-ci-iot-registry-state-push" - push_endpoint = "https://${var.project_id}.appspot.com/" - x-goog-version = "v1beta1" - ack_deadline_seconds = 20 - }, - ] - pull_subscriptions = [] - } -} diff --git a/examples/cloudiot/outputs.tf b/examples/cloudiot/outputs.tf deleted file mode 100644 index 6ee47e2..0000000 --- a/examples/cloudiot/outputs.tf +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "project_id" { - value = var.project_id - description = "The project ID" -} - -output "region" { - value = module.iot.region - description = "The region for the IoT resources" -} - -output "registry_name" { - value = module.iot.name - description = "The name of the Pub/Sub topic created" -} diff --git a/examples/cloudiot/variables.tf b/examples/cloudiot/variables.tf deleted file mode 100644 index 5abd8d8..0000000 --- a/examples/cloudiot/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - type = string - description = "The project ID to manage the Pub/Sub resources" -} diff --git a/examples/cloudiot/versions.tf b/examples/cloudiot/versions.tf deleted file mode 100644 index 7a019d7..0000000 --- a/examples/cloudiot/versions.tf +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_providers { - google = { - source = "hashicorp/google" - version = "~> 4.1" - } - tls = { - source = "hashicorp/tls" - } - } - required_version = ">= 0.13" -} diff --git a/kitchen.yml b/kitchen.yml index b68fc52..16d1af2 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -35,7 +35,3 @@ suites: driver: name: terraform root_module_directory: test/fixtures/pubsub - - name: cloudiot - driver: - name: terraform - root_module_directory: test/fixtures/cloudiot diff --git a/metadata.yaml b/metadata.yaml index e12ecc4..0fcc41b 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -27,14 +27,9 @@ spec: actuationTool: type: Terraform version: '>= 0.13' - subBlueprints: - - name: cloudiot - location: modules/cloudiot examples: - name: bigquery location: examples/bigquery - - name: cloudiot - location: examples/cloudiot - name: kms location: examples/kms - name: simple @@ -129,12 +124,10 @@ spec: roles: - level: Project roles: - - roles/cloudiot.admin - roles/pubsub.admin - roles/resourcemanager.projectIamAdmin - roles/bigquery.admin services: - - cloudiot.googleapis.com - cloudresourcemanager.googleapis.com - pubsub.googleapis.com - serviceusage.googleapis.com diff --git a/modules/cloudiot/README.md b/modules/cloudiot/README.md deleted file mode 100644 index 9d4a944..0000000 --- a/modules/cloudiot/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# terraform-google-pubsub for Cloud IoT - -## Overview - -In the early stage, this module will simply be implemented by using [existing pubsub module](https://github.com/terraform-google-modules/terraform-google-pubsub) and [one resource](https://www.terraform.io/docs/providers/google/r/cloudiot_registry.html). - -This module may not improve drastically efficiency. However, after implementing new resources like [terraform-provider-google#1495](https://github.com/terraform-providers/terraform-provider-google/issues/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. - -```hcl -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
})
{| 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`. |
"create_topic": false,
"pull_subscriptions": [],
"push_subscriptions": [],
"topic": "",
"topic_labels": {}
}
object({|
topic = string
topic_labels = map(string)
push_subscriptions = list(map(string))
pull_subscriptions = list(map(string))
create_topic = bool
})
{| 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 diff --git a/modules/cloudiot/main.tf b/modules/cloudiot/main.tf deleted file mode 100644 index f642c82..0000000 --- a/modules/cloudiot/main.tf +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -locals { - state_notification_enabled = var.state_notification_config.topic != "" ? "enabled" : "disabled" - state_notification_configs = { - disabled = null - enabled = { - pubsub_topic_name = "projects/${var.project_id}/topics/${var.state_notification_config.topic}" - } - } - state_notification_config = local.state_notification_configs[local.state_notification_enabled] - - event_notification_enabled = var.event_notification_config.topic != "" ? "enabled" : "disabled" - event_notification_configs = { - disabled = [] - enabled = [{ - pubsub_topic_name = "projects/${var.project_id}/topics/${var.event_notification_config.topic}" - }] - } - event_notification_config = local.event_notification_configs[local.event_notification_enabled] -} - -resource "google_cloudiot_registry" "default" { - name = var.name - project = var.project_id - region = var.region - - http_config = { - http_enabled_state = var.http_enabled_state - } - mqtt_config = { - mqtt_enabled_state = var.mqtt_enabled_state - } - - dynamic "event_notification_configs" { - for_each = local.event_notification_config - iterator = c - content { - pubsub_topic_name = c.value.pubsub_topic_name - } - } - - state_notification_config = local.state_notification_config - - dynamic "credentials" { - for_each = [for c in var.public_key_certificates : { - public_key_certificate = { - format = c.format - certificate = c.certificate - } - }] - content { - public_key_certificate = credentials.value.public_key_certificate - } - } - depends_on = [ - module.event_notification_topic, - module.state_notification_topic, - ] -} - -module "event_notification_topic" { - source = "../../" - project_id = var.project_id - - topic = var.event_notification_config.topic - topic_labels = var.event_notification_config.topic_labels - push_subscriptions = var.event_notification_config.push_subscriptions - pull_subscriptions = var.event_notification_config.pull_subscriptions - create_topic = var.event_notification_config.create_topic -} - -module "state_notification_topic" { - source = "../../" - project_id = var.project_id - - topic = var.state_notification_config.topic - topic_labels = var.state_notification_config.topic_labels - push_subscriptions = var.state_notification_config.push_subscriptions - pull_subscriptions = var.state_notification_config.pull_subscriptions - create_topic = var.state_notification_config.create_topic -} diff --git a/modules/cloudiot/metadata.yaml b/modules/cloudiot/metadata.yaml deleted file mode 100644 index 376feaf..0000000 --- a/modules/cloudiot/metadata.yaml +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: blueprints.cloud.google.com/v1alpha1 -kind: BlueprintMetadata -metadata: - name: terraform-google-pubsub - annotations: - config.kubernetes.io/local-config: "true" -spec: - title: terraform-google-pubsub for Cloud IoT - source: - repo: https://github.com/terraform-google-modules/terraform-google-pubsub - sourceType: git - version: 4.0.1 - actuationTool: - type: Terraform - version: '>= 0.13' - examples: - - name: bigquery - location: examples/bigquery - - name: cloudiot - location: examples/cloudiot - - name: kms - location: examples/kms - - name: simple - location: examples/simple - - name: subscriptions_only - location: examples/subscriptions_only - variables: - - name: event_notification_config - description: The event notification configuration for the Cloud IoT registry. This contains `topic`, `topic_labels`, `pull_subscriptions` and `push_subscriptions` and `create_topic`. - type: |- - object({ - topic = string - topic_labels = map(string) - push_subscriptions = list(map(string)) - pull_subscriptions = list(map(string)) - create_topic = bool - }) - default: - create_topic: false - pull_subscriptions: [] - push_subscriptions: [] - topic: "" - topic_labels: {} - required: false - - name: http_enabled_state - description: The field allows HTTP_ENABLED or HTTP_DISABLED - type: string - default: HTTP_DISABLED - required: false - - name: mqtt_enabled_state - description: The field allows MQTT_ENABLED or MQTT_DISABLED - type: string - default: MQTT_ENABLED - required: false - - name: name - description: The Cloud IoT registry name - type: string - required: true - - name: project_id - description: The project ID to manage the Cloud IoT resources - type: string - required: true - - name: public_key_certificates - description: The list for public key certificates - type: list(object({ format = string, certificate = string })) - default: [] - required: false - - name: region - description: The region to host the registry - type: string - required: true - - name: state_notification_config - description: The state notification configuration for the Cloud IoT registry. This contains `topic`, `topic_labels`, `pull_subscriptions` and `push_subscriptions` and `create_topic`. - type: |- - object({ - topic = string - topic_labels = map(string) - push_subscriptions = list(map(string)) - pull_subscriptions = list(map(string)) - create_topic = bool - }) - default: - create_topic: false - pull_subscriptions: [] - push_subscriptions: [] - topic: "" - topic_labels: {} - required: false - outputs: - - name: credentials - description: The credentials for Cloud IoT registry - - name: event_notification_subscription_names - description: The name list of Pub/Sub subscriptions associated with the registry - - name: event_notification_subscription_paths - description: The path list of Pub/Sub subscriptions associated with the registry - - name: event_notification_topic - description: The name of the Pub/Sub topic associated with the registry - - name: event_notification_topic_id - description: The id of the Pub/Sub topic associated with the registry - - name: name - description: The name of the Cloud IoT registry - - name: region - description: The region of the Cloud IoT registry - - name: registry - description: The registry being created by this module - - name: state_notification_subscription_names - description: The name list of Pub/Sub subscriptions associated with the registry - - name: state_notification_subscription_paths - description: The path list of Pub/Sub subscriptions associated with the registry - - name: state_notification_topic - description: The name of the Pub/Sub topic associated with the registry - - name: state_notification_topic_id - description: The id of the Pub/Sub topic associated with the registry - roles: - - level: Project - roles: - - roles/cloudiot.admin - - roles/pubsub.admin - - roles/resourcemanager.projectIamAdmin - - roles/bigquery.admin - services: - - cloudiot.googleapis.com - - cloudresourcemanager.googleapis.com - - pubsub.googleapis.com - - serviceusage.googleapis.com - - bigquery.googleapis.com diff --git a/modules/cloudiot/outputs.tf b/modules/cloudiot/outputs.tf deleted file mode 100644 index 680880b..0000000 --- a/modules/cloudiot/outputs.tf +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "name" { - value = google_cloudiot_registry.default.name - description = "The name of the Cloud IoT registry" -} - -output "registry" { - value = google_cloudiot_registry.default - description = "The registry being created by this module" -} - -output "region" { - value = google_cloudiot_registry.default.region - description = "The region of the Cloud IoT registry" -} - -output "credentials" { - value = google_cloudiot_registry.default.credentials.* - description = "The credentials for Cloud IoT registry" -} - -output "event_notification_topic" { - value = module.event_notification_topic.topic - description = "The name of the Pub/Sub topic associated with the registry" -} - -output "event_notification_topic_id" { - value = module.event_notification_topic.id - description = "The id of the Pub/Sub topic associated with the registry" -} - -output "event_notification_subscription_names" { - value = module.event_notification_topic.subscription_names - description = "The name list of Pub/Sub subscriptions associated with the registry" -} - -output "event_notification_subscription_paths" { - value = module.event_notification_topic.subscription_paths - description = "The path list of Pub/Sub subscriptions associated with the registry" -} - -output "state_notification_topic" { - value = module.state_notification_topic.topic - description = "The name of the Pub/Sub topic associated with the registry" -} - -output "state_notification_topic_id" { - value = module.state_notification_topic.id - description = "The id of the Pub/Sub topic associated with the registry" -} - -output "state_notification_subscription_names" { - value = module.state_notification_topic.subscription_names - description = "The name list of Pub/Sub subscriptions associated with the registry" -} - -output "state_notification_subscription_paths" { - value = module.state_notification_topic.subscription_paths - description = "The path list of Pub/Sub subscriptions associated with the registry" -} diff --git a/modules/cloudiot/variables.tf b/modules/cloudiot/variables.tf deleted file mode 100644 index 938c364..0000000 --- a/modules/cloudiot/variables.tf +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - type = string - description = "The project ID to manage the Cloud IoT resources" -} - -variable "region" { - type = string - description = "The region to host the registry" -} - -variable "name" { - type = string - description = "The Cloud IoT registry name" -} - -variable "mqtt_enabled_state" { - type = string - description = "The field allows MQTT_ENABLED or MQTT_DISABLED" - default = "MQTT_ENABLED" -} - -variable "http_enabled_state" { - type = string - description = "The field allows HTTP_ENABLED or HTTP_DISABLED" - default = "HTTP_DISABLED" -} - -variable "public_key_certificates" { - type = list(object({ format = string, certificate = string })) - description = "The list for public key certificates" - default = [] -} - -variable "event_notification_config" { - type = object({ - topic = string - topic_labels = map(string) - push_subscriptions = list(map(string)) - pull_subscriptions = list(map(string)) - create_topic = bool - }) - description = "The event notification configuration for the Cloud IoT registry. This contains `topic`, `topic_labels`, `pull_subscriptions` and `push_subscriptions` and `create_topic`." - default = { - topic = "" - topic_labels = {} - push_subscriptions = [] - pull_subscriptions = [] - create_topic = false - } -} - -variable "state_notification_config" { - type = object({ - topic = string - topic_labels = map(string) - push_subscriptions = list(map(string)) - pull_subscriptions = list(map(string)) - create_topic = bool - }) - description = "The state notification configuration for the Cloud IoT registry. This contains `topic`, `topic_labels`, `pull_subscriptions` and `push_subscriptions` and `create_topic`." - default = { - topic = "" - topic_labels = {} - push_subscriptions = [] - pull_subscriptions = [] - create_topic = false - } -} diff --git a/modules/cloudiot/versions.tf b/modules/cloudiot/versions.tf deleted file mode 100644 index f7ec86c..0000000 --- a/modules/cloudiot/versions.tf +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_version = ">= 0.13" - required_providers { - - google = { - source = "hashicorp/google" - version = ">= 4.1, < 5.0" - } - } - - provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-pubsub:cloudiot/v5.0.0" - } - -} diff --git a/test/integration/cloudiot/cloudiot_test.go b/test/integration/cloudiot/cloudiot_test.go deleted file mode 100755 index ba7a544..0000000 --- a/test/integration/cloudiot/cloudiot_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package cloudiot - -import ( - "fmt" - "testing" - - "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud" - "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" - "github.com/stretchr/testify/assert" -) - -func TestCloudIot(t *testing.T) { - bpt := tft.NewTFBlueprintTest(t) - - bpt.DefineVerify(func(assert *assert.Assertions) { - bpt.DefaultVerify(assert) - - projectId := bpt.GetStringOutput("project_id") - - op := gcloud.Runf(t, "iot registries describe cft-ci-iot-registry --region=%s --project=%s", "us-central1", projectId) - assert.Equal(fmt.Sprintf("projects/%s/locations/%s/registries/cft-ci-iot-registry", projectId, "us-central1"), op.Get("name").String(), "has expected name") - - topicSuffixes := []string{"event-topic", "state-topic"} - for _, suffix := range topicSuffixes { - op = gcloud.Runf(t, "pubsub topics describe cft-ci-iot-registry-%s --project=%s", suffix, projectId) - assert.Equal(fmt.Sprintf("projects/%s/topics/cft-ci-iot-registry-%s", projectId, suffix), op.Get("name").String(), "has expected name") - - } - subSuffixes := []string{"event-pull", "state-push"} - for _, suffix := range subSuffixes { - op = gcloud.Runf(t, "pubsub subscriptions describe cft-ci-iot-registry-%s --project=%s", suffix, projectId) - assert.Equal(fmt.Sprintf("projects/%s/subscriptions/cft-ci-iot-registry-%s", projectId, suffix), op.Get("name").String(), "has expected name") - } - }) - - bpt.Test() -} diff --git a/test/setup/iam.tf b/test/setup/iam.tf index ee41689..a501766 100644 --- a/test/setup/iam.tf +++ b/test/setup/iam.tf @@ -16,7 +16,6 @@ locals { int_required_roles = [ - "roles/cloudiot.admin", "roles/pubsub.admin", "roles/resourcemanager.projectIamAdmin", "roles/bigquery.admin" @@ -45,7 +44,7 @@ resource "google_service_account_key" "int_test" { service_account_id = google_service_account.int_test.id } -// Even if granting roles/cloudiot.admin to the service account in advance, +// Even if granting IAM roles to the service account in advance, // the roles cannot be applied immediately. As a result, our test will fail. // To avoid that, we use null_resource for `sleep`ing 60 seconds. resource "null_resource" "delay" { diff --git a/test/setup/main.tf b/test/setup/main.tf index 5e852c8..b4f07ec 100644 --- a/test/setup/main.tf +++ b/test/setup/main.tf @@ -25,7 +25,6 @@ module "project-ci-int-pubsub" { billing_account = var.billing_account activate_apis = [ - "cloudiot.googleapis.com", "cloudresourcemanager.googleapis.com", "pubsub.googleapis.com", "serviceusage.googleapis.com",
"create_topic": false,
"pull_subscriptions": [],
"push_subscriptions": [],
"topic": "",
"topic_labels": {}
}