Skip to content

Commit 646dc9f

Browse files
authored
fix: provider_meta and test boilerplate (#6)
1 parent 53fbd2f commit 646dc9f

File tree

9 files changed

+18
-13
lines changed

9 files changed

+18
-13
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Make will use bash instead of sh
1919
SHELL := /usr/bin/env bash
2020

21-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.19
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ These sections describe requirements for using this module.
7272
The following dependencies must be available:
7373

7474
- [Terraform][terraform] v0.13
75-
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v3.0
75+
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v3.53
7676

7777
### Service Account
7878

build/int.cloudbuild.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ tags:
3838
- 'integration'
3939
substitutions:
4040
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
41-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1'
41+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.19'

examples/simple_example/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ This example illustrates how to use the `enterprise-application` module.
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10-
| bucket\_name | The name of the bucket to create. | `string` | n/a | yes |
1110
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |
1211

1312
## Outputs
1413

1514
| Name | Description |
1615
|------|-------------|
1716
| bucket\_name | The name of the bucket. |
17+
| project\_id | The ID of the project in which to provision resources. |
1818

1919
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2020

examples/simple_example/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ module "enterprise_application" {
1818
source = "../.."
1919

2020
project_id = var.project_id
21-
bucket_name = var.bucket_name
21+
bucket_name = "${var.project_id}-bucket"
2222
}

examples/simple_example/outputs.tf

+5
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ output "bucket_name" {
1818
description = "The name of the bucket."
1919
value = module.enterprise_application.bucket_name
2020
}
21+
22+
output "project_id" {
23+
description = "The ID of the project in which to provision resources."
24+
value = var.project_id
25+
}

examples/simple_example/variables.tf

-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,3 @@ variable "project_id" {
1818
description = "The ID of the project in which to provision resources."
1919
type = string
2020
}
21-
22-
variable "bucket_name" {
23-
description = "The name of the bucket to create."
24-
type = string
25-
}

test/integration/simple_example/simple_example_test.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package multiple_buckets
1616

1717
import (
18+
"fmt"
1819
"testing"
1920

2021
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud"
@@ -30,10 +31,14 @@ func TestSimpleExample(t *testing.T) {
3031
example.DefaultVerify(assert)
3132

3233
projectID := example.GetStringOutput("project_id")
34+
bucketName := example.GetStringOutput("bucket_name")
35+
3336
services := gcloud.Run(t, "services list", gcloud.WithCommonArgs([]string{"--project", projectID, "--format", "json"})).Array()
37+
projectMatch := utils.GetFirstMatchResult(t, services, "config.name", "storage-api.googleapis.com")
38+
assert.Equal("ENABLED", projectMatch.Get("state").String(), "storage service should be enabled")
3439

35-
match := utils.GetFirstMatchResult(t, services, "config.name", "storage.googleapis.com")
36-
assert.Equal("ENABLED", match.Get("state").String(), "storage service should be enabled")
40+
bucket := gcloud.Run(t, fmt.Sprintf("storage ls --buckets gs://%s", bucketName), gcloud.WithCommonArgs([]string{"--project", projectID, "--json"})).Array()[0]
41+
assert.Equal(fmt.Sprintf("gs://%s/", bucketName), bucket.Get("url").String(), "bucket should exist")
3742
})
3843
example.Test()
3944
}

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ terraform {
2424
}
2525

2626
provider_meta "google" {
27-
module_name = "blueprints/terraform/enterprise-application/v0.0.1"
27+
module_name = "blueprints/terraform/terraform-google-enterprise-application/v0.0.1"
2828
}
2929
}

0 commit comments

Comments
 (0)