Skip to content

Commit f278ff8

Browse files
authored
fix: fixes lint issues and generates metadata (#171)
Co-authored-by: Awais Malik <awmalik@google.com>
1 parent 85f8e7b commit f278ff8

File tree

12 files changed

+480
-13
lines changed

12 files changed

+480
-13
lines changed

.kitchen.yml

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ suites:
3131
name: terraform
3232
command_timeout: 1800
3333
root_module_directory: test/fixtures/full
34+
# setting version verification to false since it requires TF to be less than v1.1
35+
verify_version: false

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.0
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.10
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

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.0'
41+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.10'

build/lint.cloudbuild.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ tags:
2121
- 'lint'
2222
substitutions:
2323
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
24-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
24+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.10'

examples/basic_view/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ This is a common practice for providing limited data in a different dataset.
88

99
| Name | Description | Type | Default | Required |
1010
|------|-------------|------|---------|:--------:|
11-
| default\_table\_expiration\_ms | Default TTL of tables using the dataset in MS. | `any` | `null` | no |
1211
| delete\_contents\_on\_destroy | (Optional) If set to true, delete all the tables in the dataset when destroying the resource; otherwise, destroying the resource will fail if tables are present. | `bool` | `null` | no |
1312
| table\_dataset\_labels | A mapping of labels to assign to the table. | `map(string)` | n/a | yes |
1413
| table\_project\_id | Project where the dataset and table are created. | `any` | n/a | yes |

examples/basic_view/variables.tf

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ variable "delete_contents_on_destroy" {
2020
default = null
2121
}
2222

23-
variable "default_table_expiration_ms" {
24-
description = "Default TTL of tables using the dataset in MS."
25-
default = null
26-
}
27-
2823
variable "table_project_id" {
2924
description = "Project where the dataset and table are created."
3025
}

metadata.yaml

+249
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: blueprints.cloud.google.com/v1alpha1
16+
kind: BlueprintMetadata
17+
metadata:
18+
name: terraform-google-bigquery
19+
annotations:
20+
config.kubernetes.io/local-config: "true"
21+
spec:
22+
title: terraform-google-bigquery
23+
source:
24+
repo: https://github.com/terraform-google-modules/terraform-google-bigquery
25+
sourceType: git
26+
version: 5.4.2
27+
actuationTool:
28+
type: Terraform
29+
version: '>= 0.13'
30+
subBlueprints:
31+
- name: authorization
32+
location: modules/authorization
33+
- name: scheduled_queries
34+
location: modules/scheduled_queries
35+
- name: udf
36+
location: modules/udf
37+
examples:
38+
- name: basic_bq
39+
location: examples/basic_bq
40+
- name: basic_view
41+
location: examples/basic_view
42+
- name: multiple_tables
43+
location: examples/multiple_tables
44+
- name: scheduled_queries
45+
location: examples/scheduled_queries
46+
variables:
47+
- name: access
48+
description: An array of objects that define dataset access for one or more entities.
49+
type: any
50+
default:
51+
- role: roles/bigquery.dataOwner
52+
special_group: projectOwners
53+
required: false
54+
- name: dataset_id
55+
description: Unique ID for the dataset being provisioned.
56+
type: string
57+
required: true
58+
- name: dataset_labels
59+
description: Key value pairs in a map for dataset labels
60+
type: map(string)
61+
default: {}
62+
required: false
63+
- name: dataset_name
64+
description: Friendly name for the dataset being provisioned.
65+
type: string
66+
required: false
67+
- name: default_table_expiration_ms
68+
description: TTL of tables using the dataset in MS
69+
type: number
70+
required: false
71+
- name: delete_contents_on_destroy
72+
description: (Optional) If set to true, delete all the tables in the dataset when destroying the resource; otherwise, destroying the resource will fail if tables are present.
73+
type: bool
74+
required: false
75+
- name: deletion_protection
76+
description: Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail
77+
type: bool
78+
default: false
79+
required: false
80+
- name: description
81+
description: Dataset description.
82+
type: string
83+
required: false
84+
- name: encryption_key
85+
description: Default encryption key to apply to the dataset. Defaults to null (Google-managed).
86+
type: string
87+
required: false
88+
- name: external_tables
89+
description: A list of objects which include table_id, expiration_time, external_data_configuration, and labels.
90+
type: |-
91+
list(object({
92+
table_id = string,
93+
autodetect = bool,
94+
compression = string,
95+
ignore_unknown_values = bool,
96+
max_bad_records = number,
97+
schema = string,
98+
source_format = string,
99+
source_uris = list(string),
100+
csv_options = object({
101+
quote = string,
102+
allow_jagged_rows = bool,
103+
allow_quoted_newlines = bool,
104+
encoding = string,
105+
field_delimiter = string,
106+
skip_leading_rows = number,
107+
}),
108+
google_sheets_options = object({
109+
range = string,
110+
skip_leading_rows = number,
111+
}),
112+
hive_partitioning_options = object({
113+
mode = string,
114+
source_uri_prefix = string,
115+
}),
116+
expiration_time = string,
117+
labels = map(string),
118+
}))
119+
default: []
120+
required: false
121+
- name: location
122+
description: The regional location for the dataset only US and EU are allowed in module
123+
type: string
124+
default: US
125+
required: false
126+
- name: materialized_views
127+
description: A list of objects which includes view_id, view_query, clustering, time_partitioning, range_partitioning, expiration_time and labels
128+
type: |-
129+
list(object({
130+
view_id = string,
131+
query = string,
132+
enable_refresh = bool,
133+
refresh_interval_ms = string,
134+
clustering = list(string),
135+
time_partitioning = object({
136+
expiration_ms = string,
137+
field = string,
138+
type = string,
139+
require_partition_filter = bool,
140+
}),
141+
range_partitioning = object({
142+
field = string,
143+
range = object({
144+
start = string,
145+
end = string,
146+
interval = string,
147+
}),
148+
}),
149+
expiration_time = string,
150+
labels = map(string),
151+
}))
152+
default: []
153+
required: false
154+
- name: project_id
155+
description: Project where the dataset and table are created
156+
type: string
157+
required: true
158+
- name: routines
159+
description: A list of objects which include routine_id, routine_type, routine_language, definition_body, return_type, routine_description and arguments.
160+
type: |-
161+
list(object({
162+
routine_id = string,
163+
routine_type = string,
164+
language = string,
165+
definition_body = string,
166+
return_type = string,
167+
description = string,
168+
arguments = list(object({
169+
name = string,
170+
data_type = string,
171+
argument_kind = string,
172+
mode = string,
173+
})),
174+
}))
175+
default: []
176+
required: false
177+
- name: tables
178+
description: A list of objects which include table_id, schema, clustering, time_partitioning, range_partitioning, expiration_time and labels.
179+
type: |-
180+
list(object({
181+
table_id = string,
182+
schema = string,
183+
clustering = list(string),
184+
time_partitioning = object({
185+
expiration_ms = string,
186+
field = string,
187+
type = string,
188+
require_partition_filter = bool,
189+
}),
190+
range_partitioning = object({
191+
field = string,
192+
range = object({
193+
start = string,
194+
end = string,
195+
interval = string,
196+
}),
197+
}),
198+
expiration_time = string,
199+
labels = map(string),
200+
}))
201+
default: []
202+
required: false
203+
- name: views
204+
description: A list of objects which include view_id and view query
205+
type: |-
206+
list(object({
207+
view_id = string,
208+
query = string,
209+
use_legacy_sql = bool,
210+
labels = map(string),
211+
}))
212+
default: []
213+
required: false
214+
outputs:
215+
- name: bigquery_dataset
216+
description: Bigquery dataset resource.
217+
- name: bigquery_external_tables
218+
description: Map of BigQuery external table resources being provisioned.
219+
- name: bigquery_tables
220+
description: Map of bigquery table resources being provisioned.
221+
- name: bigquery_views
222+
description: Map of bigquery view resources being provisioned.
223+
- name: external_table_ids
224+
description: Unique IDs for any external tables being provisioned
225+
- name: external_table_names
226+
description: Friendly names for any external tables being provisioned
227+
- name: project
228+
description: Project where the dataset and tables are created
229+
- name: routine_ids
230+
description: Unique IDs for any routine being provisioned
231+
- name: table_ids
232+
description: Unique id for the table being provisioned
233+
- name: table_names
234+
description: Friendly name for the table being provisioned
235+
- name: view_ids
236+
description: Unique id for the view being provisioned
237+
- name: view_names
238+
description: friendlyname for the view being provisioned
239+
roles:
240+
- level: Project
241+
roles:
242+
- roles/bigquery.admin
243+
- roles/cloudkms.cryptoKeyEncrypterDecrypter
244+
services:
245+
- cloudkms.googleapis.com
246+
- cloudresourcemanager.googleapis.com
247+
- bigquery.googleapis.com
248+
- bigquerystorage.googleapis.com
249+
- serviceusage.googleapis.com

modules/authorization/metadata.yaml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: blueprints.cloud.google.com/v1alpha1
16+
kind: BlueprintMetadata
17+
metadata:
18+
name: terraform-google-bigquery
19+
annotations:
20+
config.kubernetes.io/local-config: "true"
21+
spec:
22+
title: BigQuery Authorized Views
23+
source:
24+
repo: https://github.com/terraform-google-modules/terraform-google-bigquery
25+
sourceType: git
26+
version: 5.4.2
27+
actuationTool:
28+
type: Terraform
29+
version: '>= 0.13'
30+
examples:
31+
- name: basic_bq
32+
location: examples/basic_bq
33+
- name: basic_view
34+
location: examples/basic_view
35+
- name: multiple_tables
36+
location: examples/multiple_tables
37+
- name: scheduled_queries
38+
location: examples/scheduled_queries
39+
variables:
40+
- name: authorized_datasets
41+
description: An array of datasets to be authorized on the dataset
42+
type: |-
43+
list(object({
44+
dataset_id = string,
45+
project_id = string,
46+
}))
47+
default: []
48+
required: false
49+
- name: authorized_views
50+
description: An array of views to give authorize for the dataset
51+
type: |-
52+
list(object({
53+
dataset_id = string,
54+
project_id = string,
55+
table_id = string # this is the view id, but we keep table_id to stay consistent as the resource
56+
}))
57+
required: true
58+
- name: dataset_id
59+
description: Unique ID for the dataset being provisioned.
60+
type: string
61+
required: true
62+
- name: project_id
63+
description: Project where the dataset and table are created
64+
type: string
65+
required: true
66+
- name: roles
67+
description: An array of objects that define dataset access for one or more entities.
68+
type: any
69+
default: []
70+
required: false
71+
outputs:
72+
- name: authorized_dataset
73+
description: Authorized datasets for the BQ dataset
74+
- name: authorized_roles
75+
description: Authorized roles for the dataset
76+
- name: authorized_views
77+
description: Authorized views for the dataset
78+
roles:
79+
- level: Project
80+
roles:
81+
- roles/bigquery.admin
82+
- roles/cloudkms.cryptoKeyEncrypterDecrypter
83+
services:
84+
- cloudkms.googleapis.com
85+
- cloudresourcemanager.googleapis.com
86+
- bigquery.googleapis.com
87+
- bigquerystorage.googleapis.com
88+
- serviceusage.googleapis.com

0 commit comments

Comments
 (0)