Skip to content

Commit f797262

Browse files
Create main.tf
1 parent 15c3c11 commit f797262

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tutorials/3_settings/main.tf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
terraform {
2+
required_providers {
3+
bytebase = {
4+
version = "3.8.0"
5+
# For local development, please use "terraform.local/bytebase/bytebase" instead
6+
source = "registry.terraform.io/bytebase/bytebase"
7+
}
8+
}
9+
}
10+
11+
provider "bytebase" {
12+
service_account = "[email protected]"
13+
service_key = "bbs_xxx"
14+
url = "https://xxx.xxx.xxx"
15+
}
16+
17+
# Step 1: Workspace profile configuration
18+
resource "bytebase_setting" "workspace_profile" {
19+
name = "settings/WORKSPACE_PROFILE"
20+
21+
workspace_profile {
22+
disallow_signup = true
23+
domains = ["example.com"]
24+
enforce_identity_domain = true
25+
external_url = "https://your-bytebase-instance.com"
26+
# Optional:
27+
# disallow_password_signin = false
28+
}
29+
}
30+
31+
# Step 2: Approval flow settings
32+
resource "bytebase_setting" "approval_flow" {
33+
name = "settings/WORKSPACE_APPROVAL"
34+
35+
approval_flow {
36+
rules {
37+
flow {
38+
title = "Project Owner → DBA → Admin"
39+
description = "Need DBA and workspace admin approval"
40+
41+
steps { role = "roles/projectOwner" }
42+
steps { role = "roles/workspaceDBA" }
43+
steps { role = "roles/workspaceAdmin" }
44+
}
45+
conditions {
46+
source = "DML"
47+
level = "MODERATE"
48+
}
49+
conditions {
50+
source = "DDL"
51+
level = "HIGH"
52+
}
53+
}
54+
}
55+
}
56+
57+
# Step 3: Risk management policies
58+
resource "bytebase_risk" "dml_moderate" {
59+
title = "DML Moderate Risk"
60+
source = "DML"
61+
level = 200
62+
active = true
63+
condition = "environment_id == \"prod\" && affected_rows >= 100"
64+
}
65+
66+
resource "bytebase_risk" "ddl_high" {
67+
title = "DDL High Risk"
68+
source = "DDL"
69+
level = 300
70+
active = true
71+
condition = "environment_id == \"prod\""
72+
}

0 commit comments

Comments
 (0)