<commit_before>/**
 * Copyright 2020 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
 *
 *     https://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.
 */

resource "google_spanner_instance" "main" {
  count        = var.terraform_spanner ? 1 : 0

  name         = var.spanner_name
  config       = "regional-${var.region}"
  display_name = var.spanner_name
  project      = var.project_id
  processing_units = 100
}

resource "google_spanner_database" "database" {
  count        = var.terraform_spanner ? 1 : 0

  instance = var.spanner_name
  name     = "my-database"
  ddl = [
    "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
    "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
  ]
  # Must specify project because provider project may be different than var.project_id
  project      = var.project_id

  depends_on = [google_spanner_instance.main]
}

resource "google_spanner_instance_iam_member" "spanner_metadata_get_iam" {
  instance = var.spanner_name
  role     = "roles/spanner.viewer"
  project  = var.project_id
  member   = "serviceAccount:${var.poller_sa_email}"<commit_msg>Lifecycle rules for num_nodes and processing_units (#56)<commit_after>/**
 * Copyright 2020 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
 *
 *     https://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.
 */

resource "google_spanner_instance" "main" {
  count        = var.terraform_spanner ? 1 : 0

  name         = var.spanner_name
  config       = "regional-${var.region}"
  display_name = var.spanner_name
  project      = var.project_id
  processing_units = 100

  lifecycle {
    ignore_changes = [num_nodes, processing_units]
  }
}

resource "google_spanner_database" "database" {
  count        = var.terraform_spanner ? 1 : 0

  instance = var.spanner_name
  name     = "my-database"
  ddl = [
    "CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
    "CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
  ]
  # Must specify project because provider project may be different than var.project_id
  project      = var.project_id

  depends_on = [google_spanner_instance.main]
}

resource "google_spanner_instance_iam_member" "spanner_metadata_get_iam" {
  instance = var.spanner_name
  role     = "roles/spanner.viewer"
  project  = var.project_id
  member   = "serviceAccount:${var.poller_sa_email}"
{'fraction_non_alphanumeric': 0.08613769682000617, 'fraction_numerical': 0.01605433775856746, 'mean_word_length': 3.544179523141655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '107304', 'n_tokens_mistral': 1012, 'n_tokens_neox': 971, 'n_words': 321}