Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Terraform resource names can't start with digits, but BQ tables can #70

Merged
merged 3 commits into from Jun 8, 2021

Conversation

adlersantos
Copy link
Member

@adlersantos adlersantos commented Jun 8, 2021

Description

Terraform resource names cannot start with digits, but BigQuery allows table names that start with digits. This means that upon terraform apply, Terraform will error out despite the BQ table name being valid for Google Cloud.

This PR prepends bqt_ to Terraform resource names for BigQuery tables that start with digits. If you have a BQ table that's named like 311_austin, then the following Terraform resource will be generated:

resource "google_bigquery_table" "bqt_311_austin" {
  table_id = "311_austin"
}

and will now be valid upon terraform apply

Checklist

  • This PR is appropriately labeled.

@adlersantos adlersantos added the bug Something isn't working or open a bugfix label Jun 8, 2021
# Terraform resource names cannot start with digits, but BigQuery allows
# table names that start with digits. We prepend `bqt_` to table names
# that doesn't comply with Terraform's naming rule.
if resource["table_id"][0].isdigit():
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL isdigit() 😁

@adlersantos adlersantos merged commit 7c0f339 into main Jun 8, 2021
@adlersantos adlersantos deleted the fix-tf-resource-naming branch June 8, 2021 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or open a bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants