Skip to content

Commit

Permalink
move tls resources to the example
Browse files Browse the repository at this point in the history
  • Loading branch information
namusyaka committed Dec 9, 2019
1 parent cae7f44 commit 42bea3f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 37 deletions.
2 changes: 0 additions & 2 deletions examples/cloudiot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
| name | The name for the Cloud IoT registry | string | n/a | yes |
| project\_id | The project ID to manage the Pub/Sub resources | string | n/a | yes |
| region | The region for the IoT resources | string | n/a | yes |
| rsa\_cert1\_pem | The first certificate for Cloud IoT registry | string | n/a | yes |
| rsa\_cert2\_pem | The second certificate for Cloud IoT registry | string | n/a | yes |

## Outputs

Expand Down
21 changes: 19 additions & 2 deletions examples/cloudiot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ provider "google" {
region = var.region
}

resource "tls_private_key" "private_keys" {
count = 2
algorithm = "RSA"
}

resource "tls_self_signed_cert" "certs" {
count = 2
key_algorithm = "RSA"
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 = var.name
Expand All @@ -29,11 +46,11 @@ module "iot" {
public_key_certificates = [
{
format = "X509_CERTIFICATE_PEM"
certificate = var.rsa_cert1_pem
certificate = tls_self_signed_cert.certs[0].cert_pem
},
{
format = "X509_CERTIFICATE_PEM"
certificate = var.rsa_cert2_pem
certificate = tls_self_signed_cert.certs[1].cert_pem
},
]
event_notification_config = {
Expand Down
10 changes: 0 additions & 10 deletions examples/cloudiot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,3 @@ variable "name" {
type = string
description = "The name for the Cloud IoT registry"
}

variable "rsa_cert1_pem" {
type = string
description = "The first certificate for Cloud IoT registry"
}

variable "rsa_cert2_pem" {
type = string
description = "The second certificate for Cloud IoT registry"
}
27 changes: 4 additions & 23 deletions test/fixtures/cloudiot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,9 @@
* limitations under the License.
*/

resource "tls_private_key" "private_keys" {
count = 2
algorithm = "RSA"
}

resource "tls_self_signed_cert" "certs" {
count = 2
key_algorithm = "RSA"
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 = "../../../examples/cloudiot"
project_id = var.project_id
name = "cft-ci-iot-registry"
region = "us-central1"
rsa_cert1_pem = tls_self_signed_cert.certs[0].cert_pem
rsa_cert2_pem = tls_self_signed_cert.certs[1].cert_pem
source = "../../../examples/cloudiot"
project_id = var.project_id
name = "cft-ci-iot-registry"
region = "us-central1"
}

0 comments on commit 42bea3f

Please sign in to comment.