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
gcloudCLI
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
| Name | Version |
|---|---|
| terraform | >= 1.12.2 |
| null | >= 3.0 |
Providers
| Name | Version |
|---|---|
| null | >= 3.0 |
Modules
No modules.
Resources
| Name | Type |
|---|---|
| null_resource.run_migrations | resource |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| database_name | The Spanner database name. | string | n/a | yes |
| instance_name | The Spanner instance name. | string | n/a | yes |
| migrations_dir | The migrations directory. | string | n/a | yes |
| project_id | The project ID to deploy to. | string | n/a | yes |
| proto_descriptors_file | Optional path to a compiled proto descriptors file (.pb) needed for custom types in migrations. | string | null | no |
| sub_directory | Optional sub-directory within migrations_dir to search for SQL files. | string | "" | no |
Outputs
| Name | Description |
|---|---|
| migration_completion_id | The ID of the migration completion anchor. |