|
1 | 1 | # This is an example for using Bytebase Terraform provider to manage your resource. |
| 2 | +# Docs: https://www.bytebase.com/docs/get-started/work-with-terraform/overview |
2 | 3 | # To run this provider in your local machine, |
3 | 4 | # 1. Run your Bytebase service, then you can access the OpenAPI via http://localhost:8080/v1 |
4 | | -# 2. Replace the email and password with your own Bytebase account |
| 5 | +# 2. Replace the service_account and service_key with your own Bytebase service account |
5 | 6 | # 3. Run `make install` under terraform-provider-bytebase folder |
6 | 7 | # 4. Run `cd examples && terraform init` |
7 | 8 | # 5. Run `terraform plan` to check the changes |
8 | 9 | # 6. Run `terraform apply` to apply the changes |
9 | 10 | # 7. Run `terraform output` to find the outputs |
10 | 11 | # 8. Run `terraform destory` to delete the test resources |
11 | 12 | provider "bytebase" { |
12 | | - # You need to replace the email and password with your own Bytebase account. |
13 | | - |
14 | | - password = "ed" |
15 | | - # The source is only used in the local example. |
16 | | - bytebase_url = "http://localhost:8080/v1" |
| 13 | + # You need to replace the account and key with your Bytebase service account. |
| 14 | + service_account = "[email protected]" |
| 15 | + service_key = "bbs_qHX6CswQ1nMMELSCc2lk" |
| 16 | + url = "https://bytebase.example.com" |
17 | 17 | } |
18 | 18 |
|
19 | 19 | locals { |
20 | | - environment_name = "dev" |
21 | | - instance_name = "dev instance" |
| 20 | + environment_name_dev = "dev" |
| 21 | + environment_name_prod = "prod" |
| 22 | + instance_name = "dev instance" |
22 | 23 | } |
23 | 24 |
|
24 | 25 | # Create a new environment named "dev" |
25 | 26 | resource "bytebase_environment" "dev" { |
26 | | - name = local.environment_name |
27 | | - # You can specific the environment order |
28 | | - # order = 1 |
| 27 | + name = local.environment_name_dev |
| 28 | + order = 0 |
| 29 | +} |
| 30 | + |
| 31 | +# Create another environment named "prod" |
| 32 | +resource "bytebase_environment" "prod" { |
| 33 | + name = local.environment_name_prod |
| 34 | + order = 1 |
29 | 35 | } |
30 | 36 |
|
31 | 37 | # Print the new environment |
@@ -56,7 +62,7 @@ output "dev_instance" { |
56 | 62 | # import environments module and filter by environment name |
57 | 63 | module "environment" { |
58 | 64 | source = "./environments" |
59 | | - environment_name = local.environment_name |
| 65 | + environment_name = local.environment_name_dev |
60 | 66 | # Make sure the module exec after the "dev" environment is created |
61 | 67 | depends_on = [ |
62 | 68 | bytebase_environment.dev |
|
0 commit comments