This tutorial is part of the Bytebase Terraform Provider series:
This tutorial series uses separate Terraform files for better organization. Files are numbered by tutorial part and sub-step (e.g., 1-1-env-setting.tf, 1-2-env-policy-rollout.tf for Part 1, 2-instances.tf for Part 2, etc.). Terraform automatically handles dependencies between files.
Create projects to organize your databases into logical groups.
Before starting this tutorial, ensure you have:
Test Sample Instance
and Prod Sample Instance
from sample dataFrom previous tutorials, you have:
hr_test
and postgres
databaseshr_prod
and postgres
databasesCurrently, these hr_test
and hr_prod
databases are in the default Sample Project
, while postgres
databases are unassigned. You can view them in Bytebase by clicking Databases on the left sidebar. Let’s organize them into new projects.
Terraform resource | bytebase_project |
Sample file | 3-projects.tf |
Create 3-projects.tf
:
Two Assignment Patterns
Dynamic: databases = bytebase_instance.test.databases
Explicit: databases = ["instances/.../databases/..."]
Go to Projects in Bytebase.
You’ll see three projects:
Sample Project (original, now empty)
Project One (contains hr_test
and postgres
which are both from Test Sample Instance
)
Project Two (contains hr_prod
which is from Prod Sample Instance
)
You’ve successfully organized databases into projects! Key takeaways: