# README
Terraform Provider Bytebase
This repository is the Terraform provider for Bytebase. A typical setup involves teams using Cloud vendors' Terraform provider to provision database instances, followed by using Terraform Bytebase Provider to prepare those instances ready for application use.
Real world example
https://github.com/bytebase/terraform-example and https://tf.bytebase.com.
Usage
You can download this provider at registry.terraform.io.
Please follow Manage Bytebase with Terraform to use the provider.
Development
Prerequisites
If you have problems running
terraform
in MacOS with Apple Silicon, you can following https://stackoverflow.com/questions/66281882/how-can-i-get-terraform-init-to-run-on-my-apple-silicon-macbook-pro-for-the-go and use thetfenv
.
Prepare Bytebase OpenAPI server
# clone Bytebase to get the OpenAPI server
git clone [email protected]:bytebase/bytebase.git
git clone [email protected]:bytebase/terraform-provider-bytebase.git
# start Bytebase OpenAPI server
cd bytebase
# check https://github.com/bytebase/bytebase for starting the Bytebase server.
air -c scripts/.air.toml
Build and test
# install the provider in your local machine
cd terraform-provider-bytebase && make install
# test
# Any BYTEBASE_SERVICE_ACCOUNT/BYTEBASE_SERVICE_KEY/BYTEBASE_URL value should work since the service is mocked
TF_ACC=1 [email protected] BYTEBASE_SERVICE_KEY=test_secret BYTEBASE_URL=https://bytebase.example.com go test -v ./...
# initialize the terraform for your example
# you need to set the service_account and service_key to your own
cd examples/setup && terraform init
# check the changes
terraform plan
# apply the changes
terraform apply
# print outputs
terraform output
# delete test resources
terraform destory
Generate docs
This will generate the doc template in the
docs
folderCheck https://github.com/hashicorp/terraform-plugin-docs for details.
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs --provider-name=terraform-provider-bytebase
Release
Follow this doc to publish the provider.
Note: We need to publish a new tag for a new version, the tag must be a valid Semantic Version preceded with a v (for example, v1.2.3). There must not be a branch name with the same name as the tag.
- Develop and merge the feature code.
- Create a new PR to update the version in
./VERSION
- After the version is updated, the action
./.github/workflows/release.yml
will use the newest versionx.y.z
to create a new tagvx.y.z
, then use the tag to create the release.