Skip to content

Commit

Permalink
Merge pull request #61 from volcengine/feat/mongodb
Browse files Browse the repository at this point in the history
Feat/mongodb
  • Loading branch information
xuyaming0800 authored Feb 16, 2023
2 parents 43767c1 + 58fce06 commit ddbd2c3
Show file tree
Hide file tree
Showing 72 changed files with 5,316 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.50"
TerraformProviderVersion = "0.0.51"
)
1 change: 1 addition & 0 deletions docgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var resourceKeys = map[string]string{
"cen": "CEN(BETA)",
"vpn": "VPN(BETA)",
"autoscaling": "AUTOSCALING",
"mongodb": "MONGODB",
}

type Products struct {
Expand Down
3 changes: 3 additions & 0 deletions example/dataMongoDBAccounts/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_accounts" "default"{
instance_id = "mongo-replica-xxx"
}
5 changes: 5 additions & 0 deletions example/dataMongoDBAllowLists/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "volcengine_mongodb_allow_lists" "default"{
region_id = "cn-xxx"
instance_id="mongo-replica-xxx"
allow_list_ids=["acl-2ecfc3318fd24bfab6xxx","acl-ada659ab83e941d6adc2xxxf"]
}
5 changes: 5 additions & 0 deletions example/dataMongoDBInstanceParameterLogs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "volcengine_mongodb_instance_parameter_logs" "foo"{
instance_id="mongo-replica-xxx"
start_time="2022-11-14 00:00Z"
end_time="2022-11-14 18:15Z"
}
3 changes: 3 additions & 0 deletions example/dataMongoDBInstanceParameters/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_instance_parameters" "foo"{
instance_id="mongo-replica-xxx"
}
2 changes: 2 additions & 0 deletions example/dataMongoDBRegions/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data "volcengine_mongodb_regions" "default"{
}
3 changes: 3 additions & 0 deletions example/dataMongoDBSSLStates/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_ssl_states" "foo"{
instance_id="mongo-shard-xxx"
}
3 changes: 3 additions & 0 deletions example/dataMongoDBSpecs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_specs" "foo"{
region_id="cn-xxx"
}
3 changes: 3 additions & 0 deletions example/dataMongoDBZones/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_zones" "default"{
region_id = "XXX"
}
3 changes: 3 additions & 0 deletions example/dataMongodbEndpoints/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_endpoints" "foo"{
instance_id="mongo-shard-xxx"
}
3 changes: 3 additions & 0 deletions example/dataMongodbInstances/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_mongodb_instances" "foo"{
instance_id="mongo-replica-xxx"
}
6 changes: 6 additions & 0 deletions example/mongoDBAllowList/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "volcengine_mongodb_allow_list" "foo"{
allow_list_name="tf-test"
allow_list_desc="test"
allow_list_type="IPv4"
allow_list="10.1.1.1,10.1.1.2,10.1.1.3,10.2.3.0/24"
}
4 changes: 4 additions & 0 deletions example/mongoDBAllowListAssociate/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "volcengine_mongodb_allow_list_associate" "foo"{
instance_id="mongo-replica-b2xxx"
allow_list_id="acl-4d66bec945d14fa48xxx"
}
6 changes: 6 additions & 0 deletions example/mongoDBEndpoint/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "volcengine_mongodb_endpoint" "foo"{
instance_id="mongo-shard-xxx"
object_id="mongo-shard-xxx-s1"
network_type="Public"
eip_ids=["eip-xx","eip-xx"]
}
5 changes: 5 additions & 0 deletions example/mongoDBEndpointImport/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "volcengine_mongodb_endpoint" "foo"{
instance_id="mongo-shard-9e031cea119b"
object_id="mongo-shard-9e031cea119b-s0"
network_type="Private"
}
15 changes: 15 additions & 0 deletions example/mongoDBInstance/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "volcengine_mongodb_instance" "foo"{
zone_id="cn-xxx"
instance_type="ShardedCluster"
node_spec="mongo.xxx"
mongos_node_spec="mongo.mongos.xxx"
shard_number=3
storage_space_gb=100
subnet_id="subnet-2d6pxxu"
instance_name="tf-test"
charge_type="PostPaid"
# period_unit="Month"
# period=1
# auto_renew=false
# ssl_action="Close"
}
6 changes: 6 additions & 0 deletions example/mongoDBInstanceParameter/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "volcengine_mongodb_instance_parameter" "foo"{
instance_id="mongo-replica-b2xxx"
parameter_name="connPoolMaxConnsPerHost"
parameter_role="Node"
parameter_value="800"
}
4 changes: 4 additions & 0 deletions example/mongoDBSSLState/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "volcengine_mongodb_ssl_state" "foo"{
instance_id="mongo-shard-xxx"
ssl_action="Update"
}
15 changes: 15 additions & 0 deletions example/mongodb/import/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "volcengine_mongodb_instance" "foo"{
# region_id="cn-xxx"
# zone_ids=["cn-xxx"]
# instance_name="test-22"
# sharded_cluster=0
# password="1qaz!QAZ"
# node_number=2
# shard_capacity=1024
# engine_version="5.0"
# vpc_id="vpc-274d24a6ece807fap8***"
# subnet_id="subnet-274o6znje5iww7fa***"
# charge_type="PrePaid"
# purchase_months=1
# auto_renew=false
}
4 changes: 2 additions & 2 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func Debug(format string, action string, req interface{}, v ...interface{}) {
message := fmt.Sprintf("[DEBUG] {(t-%v):%v:%v}", GetGID(), file, line)
log.Printf(message+format, action, req, v)
}
func DebugInfo(format string, info interface{}) {
func DebugInfo(format string, info ...interface{}) {
_, file, line, _ := runtime.Caller(skip)
start := strings.LastIndex(file, "/")
if start != -1 {
file = file[start+1:]
}
message := fmt.Sprintf("[DEBUG] {%v:%v}", file, line)
log.Printf(message+format, info)
log.Printf(message+format, info...)
}

func Info(format string, v ...interface{}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package account

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
ve "github.com/volcengine/terraform-provider-volcengine/common"
)

func DataSourceVolcengineMongoDBAccounts() *schema.Resource {
return &schema.Resource{
Read: dataSourceVolcengineAccountsRead,
Schema: map[string]*schema.Schema{
"instance_id": {
Type: schema.TypeString,
Required: true,
// ForceNew: true,
Description: "Target query mongo instance id.",
},
"account_name": {
Type: schema.TypeString,
Optional: true,
Description: "The name of account, current support only `root`.",
ValidateFunc: validation.StringInSlice([]string{"root"}, false),
},
"output_file": {
Type: schema.TypeString,
Optional: true,
Description: "File name where to save data source results.",
},
"total_count": {
Type: schema.TypeInt,
Computed: true,
Description: "The total count of accounts query.",
},
"accounts": {
Description: "The collection of accounts query.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of account.",
},
"account_type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of account.",
},
"account_privileges": {
Type: schema.TypeList,
Computed: true,
Description: "The privilege info of mongo instance.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"db_name": {
Type: schema.TypeString,
Computed: true,
Description: "The Name of DB.",
},
"role_name": {
Type: schema.TypeString,
Computed: true,
Description: "The Name of role.",
},
},
},
},
},
},
},
},
}
}

func dataSourceVolcengineAccountsRead(d *schema.ResourceData, meta interface{}) error {
regionService := NewMongoDBAccountService(meta.(*ve.SdkClient))
return regionService.Dispatcher.Data(regionService, d, DataSourceVolcengineMongoDBAccounts())
}
Loading

0 comments on commit ddbd2c3

Please sign in to comment.