Skip to content

Commit

Permalink
Updated examples, support for multiple tables, updated google provide…
Browse files Browse the repository at this point in the history
…r in examples, changed fixtures, updated Gems
  • Loading branch information
adigangi committed Apr 30, 2019
1 parent 3e6d95f commit 05d21ff
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ verifier:
name: terraform
systems:
- name: system
backend: local
backend: gcp

suites:
- name: full
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.0] 2019-04-30

### Added
- Support for multiple tables per [Issue #6](https://github.com/terraform-google-modules/terraform-google-bigquery/issues/6)
- Examples to support google provider >2.5.0 per [Issue #8](https://github.com/terraform-google-modules/terraform-google-bigquery/issues/8)
- Upgraded Gemfile/Gemfile.lock for kitchen-terraform gems
- Module output for table name

### Changed
- Module ONLY accepts a _list of maps_ for the table_name, table_id, and schema. This enables the creation of multiple tables on a single dataset.
- Inspec attributes for testing in inspec.yml

### Improved
- Examples for multiple tables pre [Issue #5](https://github.com/terraform-google-modules/terraform-google-bigquery/issues/5)
- Testing with native inspec resources per [Issue #7](https://github.com/terraform-google-modules/terraform-google-bigquery/issues/7)

[0.2.0]: https://github.com/terraform-google-modules/terraform-google-bigquery/tree/v0.2.0/

## [0.1.0] 2019-02-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
source "https://rubygems.org/" do
gem(
"kitchen-terraform",
"~> 4.1"
"~> 4.8"
)
end
111 changes: 60 additions & 51 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
aws-sdk (2.11.197)
aws-sdk-resources (= 2.11.197)
aws-sdk-core (2.11.197)
aws-eventstream (1.0.3)
aws-sdk (2.11.264)
aws-sdk-resources (= 2.11.264)
aws-sdk-core (2.11.264)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.197)
aws-sdk-core (= 2.11.197)
aws-sigv4 (1.0.3)
azure_graph_rbac (0.17.0)
aws-sdk-resources (2.11.264)
aws-sdk-core (= 2.11.264)
aws-sigv4 (1.1.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_graph_rbac (0.17.1)
ms_rest_azure (~> 0.11.0)
azure_mgmt_key_vault (0.17.2)
azure_mgmt_key_vault (0.17.4)
ms_rest_azure (~> 0.11.0)
azure_mgmt_resources (0.17.2)
azure_mgmt_resources (0.17.4)
ms_rest_azure (~> 0.11.0)
builder (3.2.3)
coderay (1.1.2)
concurrent-ruby (1.1.4)
concurrent-ruby (1.1.5)
declarative (0.0.10)
declarative-option (0.1.0)
diff-lcs (1.3)
Expand All @@ -28,44 +30,45 @@ GEM
multi_json
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dry-configurable (0.7.0)
dry-configurable (0.8.2)
concurrent-ruby (~> 1.0)
dry-container (0.6.0)
dry-core (~> 0.4, >= 0.4.7)
dry-container (0.7.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.7)
concurrent-ruby (~> 1.0)
dry-equalizer (0.2.1)
dry-equalizer (0.2.2)
dry-inflector (0.1.2)
dry-logic (0.4.2)
dry-container (~> 0.2, >= 0.2.6)
dry-logic (0.6.1)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-types (0.13.4)
dry-types (0.14.1)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.2)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 0.4, >= 0.4.2)
dry-validation (0.12.2)
dry-logic (~> 0.5, >= 0.5)
dry-validation (0.13.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (~> 0.2, >= 0.2.1)
dry-equalizer (~> 0.2)
dry-logic (~> 0.4, >= 0.4.0)
dry-types (~> 0.13.1)
dry-logic (~> 0.5, >= 0.5.0)
dry-types (~> 0.14, >= 0.14)
equatable (0.5.0)
erubis (2.7.0)
excon (0.62.0)
excon (0.64.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
ffi (1.9.25)
ffi (1.10.0)
google-api-client (0.23.9)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.5, < 0.7.0)
Expand All @@ -91,7 +94,7 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
inifile (3.0.0)
inspec (3.2.6)
inspec (3.9.3)
addressable (~> 2.4)
faraday (>= 0.9.0)
faraday_middleware (~> 0.12.2)
Expand All @@ -112,18 +115,21 @@ GEM
term-ansicolor
thor (~> 0.20)
tomlrb (~> 1.2)
train (~> 1.5, >= 1.6.3)
train (~> 1.5, >= 1.7.2)
train-habitat (~> 0.1)
tty-prompt (~> 0.17)
tty-table (~> 0.10)
jmespath (1.4.0)
json (2.1.0)
jwt (2.1.0)
kitchen-terraform (4.1.1)
dry-types (~> 0.9)
dry-validation (~> 0.10)
kitchen-terraform (4.8.0)
dry-types (~> 0.14.0)
dry-validation (= 0.13.0)
inspec (~> 3.0)
json (~> 2.1.0)
mixlib-shellout (~> 2.2)
test-kitchen (~> 1.23)
tty-which (~> 0.4.0)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
Expand All @@ -132,12 +138,12 @@ GEM
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mixlib-install (3.11.5)
mime-types-data (3.2019.0331)
mixlib-install (3.11.12)
mixlib-shellout
mixlib-versioning
thor
mixlib-log (2.0.9)
mixlib-log (3.0.1)
mixlib-shellout (2.4.4)
mixlib-versioning (1.2.7)
ms_rest (0.7.3)
Expand All @@ -158,8 +164,8 @@ GEM
net-ssh-gateway (1.3.0)
net-ssh (>= 2.6.5)
nori (2.6.0)
os (1.0.0)
parallel (1.12.1)
os (1.0.1)
parallel (1.17.0)
parslet (1.8.2)
pastel (0.7.2)
equatable (~> 0.5.0)
Expand All @@ -179,10 +185,10 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
rspec-expectations (3.8.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-its (1.2.0)
rspec-its (1.3.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.8.0)
Expand All @@ -197,13 +203,13 @@ GEM
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
sslshake (1.2.0)
strings (0.1.4)
strings-ansi (~> 0.1.0)
unicode-display_width (~> 1.4.0)
unicode_utils (~> 1.4.0)
sslshake (1.3.0)
strings (0.1.5)
strings-ansi (~> 0.1)
unicode-display_width (~> 1.5)
unicode_utils (~> 1.4)
strings-ansi (0.1.0)
term-ansicolor (1.7.0)
term-ansicolor (1.7.1)
tins (~> 1.0)
test-kitchen (1.24.0)
mixlib-install (~> 3.6)
Expand All @@ -216,11 +222,11 @@ GEM
winrm-elevated (~> 1.0)
winrm-fs (~> 1.1)
thor (0.20.3)
timeliness (0.3.8)
timers (4.2.0)
timeliness (0.4.0)
timers (4.3.0)
tins (1.20.2)
tomlrb (1.2.8)
train (1.6.3)
train (1.7.6)
aws-sdk (~> 2)
azure_graph_rbac (~> 0.16)
azure_mgmt_key_vault (~> 0.17)
Expand All @@ -230,14 +236,16 @@ GEM
googleauth (~> 0.6.6)
inifile
json (>= 1.8, < 3.0)
mixlib-shellout (~> 2.0)
mixlib-shellout (>= 2.0)
net-scp (~> 1.2)
net-ssh (>= 2.9, < 6.0)
winrm (~> 2.0)
winrm-fs (~> 1.0)
train-habitat (0.1.1)
train (>= 1.7.5, < 3.0)
tty-color (0.4.3)
tty-cursor (0.6.0)
tty-prompt (0.18.0)
tty-cursor (0.6.1)
tty-prompt (0.18.1)
necromancer (~> 0.4.0)
pastel (~> 0.7.0)
timers (~> 4.0)
Expand All @@ -254,13 +262,14 @@ GEM
pastel (~> 0.7.2)
strings (~> 0.1.0)
tty-screen (~> 0.6.4)
tty-which (0.4.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.1)
unf_ext (0.0.7.6)
unicode-display_width (1.5.0)
unicode_utils (1.4.0)
winrm (2.3.1)
winrm (2.3.2)
builder (>= 2.1.2)
erubis (~> 2.7)
gssapi (~> 1.2)
Expand All @@ -283,7 +292,7 @@ PLATFORMS
ruby

DEPENDENCIES
kitchen-terraform (~> 4.1)!
kitchen-terraform (~> 4.8)!

BUNDLED WITH
1.17.3
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This module provisions a dataset and a table with an associated JSON schema.
## Requirements
### Terraform plugins
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v1.20.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v2.5.0

### Permissions
In order to execute this module you must have a Service Account with the following roles:
Expand All @@ -56,8 +56,11 @@ To set this up on your machine, follow the official [Kitchen installation](https
- Kitchen tests are located: [test/integration/full](test/integration/full).
- Terraform fixtures are located: [test/fixtures/full](test/fixtures/full).

## Running tests
### macOS mojave notes
To run kitchen tests on macOS > 10.14.4 xcode will need to be [reset](https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a)
`xcode-select --install`

## Running tests
`cd /path/to/terraform-google-bigquery`
The following command will run all tests for the module:
`make`
5 changes: 5 additions & 0 deletions examples/basic_bq/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ output "table_id" {
description = "Unique id for the table being provisioned"
}

output "table_name" {
value = "${module.bigquery.table_name}"
description = "Friendly name for the table being provisioned"
}

output "dataset_labels" {
value = "${module.bigquery.dataset_labels}"
description = "Key value pairs in a map for dataset labels"
Expand Down
16 changes: 16 additions & 0 deletions examples/multiple_tables/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* 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 configuration
*****************************************/
Expand Down
5 changes: 5 additions & 0 deletions examples/multiple_tables/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ output "table_id" {
description = "Unique id for the table being provisioned"
}

output "table_name" {
value = "${module.bigquery.table_name}"
description = "Friendly name for the table being provisioned"
}

output "dataset_labels" {
value = "${module.bigquery.dataset_labels}"
description = "Key value pairs in a map for dataset labels"
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple_tables/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
expiration = 3600000
project_id = "test-adigangi"
project_id = "example-project"
time_partitioning = "DAY"
dataset_labels = {
env = "dev"
Expand Down
8 changes: 1 addition & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
* limitations under the License.
*/

/******************************************
Locals configuration
*****************************************/
locals {

}

resource "google_bigquery_dataset" "main" {
dataset_id = "${var.dataset_id}"
friendly_name = "${var.dataset_name}"
Expand All @@ -35,6 +28,7 @@ resource "google_bigquery_dataset" "main" {
resource "google_bigquery_table" "main" {
count = "${length(var.tables)}"
dataset_id = "${google_bigquery_dataset.main.dataset_id}"
friendly_name = "${lookup(var.tables[count.index], "table_id")}"
table_id = "${lookup(var.tables[count.index], "table_id")}"
project = "${var.project_id}"

Expand Down
Loading

0 comments on commit 05d21ff

Please sign in to comment.