Skip to content

Commit

Permalink
feat!: Schema should now be passed as a JSON string instead of a file…
Browse files Browse the repository at this point in the history
… path (#111)
  • Loading branch information
bharathkkb authored Mar 15, 2021
1 parent 66311eb commit 7180061
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module "bigquery" {
tables = [
{
table_id = "foo",
schema = "<PATH TO THE SCHEMA JSON FILE>",
schema = "<SCHEMA JSON DATA>",
time_partitioning = {
type = "DAY",
field = null,
Expand All @@ -56,7 +56,7 @@ module "bigquery" {
},
{
table_id = "bar",
schema = "<PATH TO THE SCHEMA JSON FILE>",
schema = "<SCHEMA JSON DATA>",
time_partitioning = null,
range_partitioning = {
field = "customer_id",
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_bq/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module "bigquery" {
tables = [
{
table_id = "bar",
schema = "sample_bq_schema.json",
schema = file("sample_bq_schema.json"),
time_partitioning = null,
range_partitioning = null,
expiration_time = 2524604400000, # 2050/01/01
Expand Down
4 changes: 2 additions & 2 deletions examples/multiple_tables/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module "bigquery" {
tables = [
{
table_id = "foo",
schema = "sample_bq_schema.json",
schema = file("sample_bq_schema.json"),
time_partitioning = {
type = "DAY",
field = null,
Expand All @@ -44,7 +44,7 @@ module "bigquery" {
},
{
table_id = "bar",
schema = "sample_bq_schema.json",
schema = file("sample_bq_schema.json"),
time_partitioning = null,
range_partitioning = {
field = "visitNumber",
Expand Down
1 change: 1 addition & 0 deletions examples/multiple_tables/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

provider "google" {
version = "~> 3.57.0"
scopes = [
# To configure an external table with a Google Sheet you must pass this scope
# see: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_table#source_format
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ resource "google_bigquery_table" "main" {
friendly_name = each.key
table_id = each.key
labels = each.value["labels"]
schema = file(each.value["schema"])
schema = each.value["schema"]
clustering = each.value["clustering"]
expiration_time = each.value["expiration_time"]
project = var.project_id
Expand Down

5 comments on commit 7180061

@rpd5003
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im having trouble defining my tables in variables files since file() cant be used in tfvars.....is there another workaround or suggested way to manage tables via variables?

@morgante
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can define the schema inline in your tfvars.

@rpd5003
Copy link

@rpd5003 rpd5003 commented on 7180061 Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then the vars file gets huge....using file makes it easier to read and maintain table changes

@bharathkkb
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use file() when you instantiate the module reading in the filename via tfvars? Please open an issue if you need further assistance.

@rpd5003
Copy link

@rpd5003 rpd5003 commented on 7180061 Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i'll open an issue. just to respond to the question....for multiple datasets with multiple tables, I am using for each to iterate over all the datasets and their respective tables. i'm not sure how that would work since tables takes a list

Please sign in to comment.