README.md

June 10, 2026 ยท View on GitHub

Description

This module runs Spanner DDL migrations from a specified directory using gcloud. It looks for .up.sql files in the specified migrations_dir (or an optional sub_directory within it) and applies them in alphabetical order.

Software Requirements

  • gcloud CLI

Example

  - id: run_migrations
    source: community/modules/scripts/spanner-migrations-runner
    settings:
      project_id: $(vars.project_id)
      instance_name: my-spanner-instance
      database_name: my-database
      migrations_dir: $(ghpc_stage("my-assets/migrations"))
      sub_directory: db1

License

Copyright 2026 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.

Requirements

NameVersion
terraform>= 1.12.2
null>= 3.0

Providers

NameVersion
null>= 3.0

Modules

No modules.

Resources

NameType
null_resource.run_migrationsresource

Inputs

NameDescriptionTypeDefaultRequired
database_nameThe Spanner database name.stringn/ayes
instance_nameThe Spanner instance name.stringn/ayes
migrations_dirThe migrations directory.stringn/ayes
project_idThe project ID to deploy to.stringn/ayes
proto_descriptors_fileOptional path to a compiled proto descriptors file (.pb) needed for custom types in migrations.stringnullno
sub_directoryOptional sub-directory within migrations_dir to search for SQL files.string""no

Outputs

NameDescription
migration_completion_idThe ID of the migration completion anchor.