Skip to content

Commit

Permalink
Merge pull request #158 from volcengine/feat/sql
Browse files Browse the repository at this point in the history
Feat/sql
  • Loading branch information
zpp12354321 authored Jan 29, 2024
2 parents a214f9e + e3cc4a3 commit 993845d
Show file tree
Hide file tree
Showing 38 changed files with 2,648 additions and 2 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.137"
TerraformProviderVersion = "0.0.138"
)
1 change: 1 addition & 0 deletions docgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ var resourceKeys = map[string]string{
"alb": "ALB",
"bandwidth_package": "BANDWIDTH_PACKAGE",
"cloud_monitor": "CLOUD_MONITOR",
"rds_mssql": "RDS_MSSQL",
}

type Products struct {
Expand Down
3 changes: 3 additions & 0 deletions example/dataRdsMssqlBackups/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_rds_mssql_backups" "foo" {
instance_id = "mssql-40914121fd22"
}
3 changes: 3 additions & 0 deletions example/dataRdsMssqlInstances/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_rds_mssql_instances" "foo" {
instance_id = "mssql-d2fc5abe****"
}
2 changes: 2 additions & 0 deletions example/dataRdsMssqlRegions/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data "volcengine_rds_mssql_regions" "foo"{
}
3 changes: 3 additions & 0 deletions example/dataRdsMssqlZones/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_rds_mssql_zones" "foo"{

}
3 changes: 3 additions & 0 deletions example/rdsMssqlBackup/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "volcengine_rds_mssql_backup" "foo" {
instance_id = "mssql-40914121fd22"
}
36 changes: 36 additions & 0 deletions example/rdsMssqlInstance/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_rds_mssql_instance" "foo" {
db_engine_version = "SQLServer_2019_Std"
instance_type = "HA"
node_spec = "rds.mssql.se.ha.d2.2c4g"
storage_space = 20
subnet_id = [volcengine_subnet.foo.id]
super_account_password = "Tftest110"
instance_name = "acc-test-mssql"
project_name = "default"
charge_info {
charge_type = "PostPaid"
}
tags {
key = "k1"
value = "v1"
}

backup_time = "18:00Z-19:00Z"
full_backup_period = ["Monday", "Tuesday"]
backup_retention_period = 14
}
15 changes: 15 additions & 0 deletions volcengine/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"github.com/volcengine/terraform-provider-volcengine/volcengine/alb/alb_server_group"
"github.com/volcengine/terraform-provider-volcengine/volcengine/alb/alb_server_group_server"
"github.com/volcengine/terraform-provider-volcengine/volcengine/alb/alb_zone"
mssqlBackup "github.com/volcengine/terraform-provider-volcengine/volcengine/rds_mssql/rds_mssql_backup"
mssqlInstance "github.com/volcengine/terraform-provider-volcengine/volcengine/rds_mssql/rds_mssql_instance"

"github.com/volcengine/terraform-provider-volcengine/volcengine/cen/cen_service_route_entry"
"github.com/volcengine/terraform-provider-volcengine/volcengine/cloud_monitor/cloud_monitor_contact"
"github.com/volcengine/terraform-provider-volcengine/volcengine/cloud_monitor/cloud_monitor_contact_group"
Expand All @@ -23,6 +26,8 @@ import (
"github.com/volcengine/terraform-provider-volcengine/volcengine/nas/nas_region"
"github.com/volcengine/terraform-provider-volcengine/volcengine/nas/nas_snapshot"
"github.com/volcengine/terraform-provider-volcengine/volcengine/nas/nas_zone"
"github.com/volcengine/terraform-provider-volcengine/volcengine/rds_mssql/rds_mssql_region"
"github.com/volcengine/terraform-provider-volcengine/volcengine/rds_mssql/rds_mssql_zone"
trEntry "github.com/volcengine/terraform-provider-volcengine/volcengine/transit_router/route_entry"
trTable "github.com/volcengine/terraform-provider-volcengine/volcengine/transit_router/route_table"
"github.com/volcengine/terraform-provider-volcengine/volcengine/transit_router/route_table_association"
Expand Down Expand Up @@ -525,6 +530,12 @@ func Provider() terraform.ResourceProvider {
"volcengine_cloud_monitor_contact_groups": cloud_monitor_contact_group.DataSourceVolcengineCloudMonitorContactGroups(),
"volcengine_cloud_monitor_event_rules": cloud_monitor_event_rule.DataSourceVolcengineCloudMonitorEventRules(),
"volcengine_cloud_monitor_rules": cloud_monitor_rule.DataSourceVolcengineCloudMonitorRules(),

// ================ RdsMssql ================
"volcengine_rds_mssql_regions": rds_mssql_region.DataSourceVolcengineRdsMssqlRegions(),
"volcengine_rds_mssql_zones": rds_mssql_zone.DataSourceVolcengineRdsMssqlZones(),
"volcengine_rds_mssql_instances": mssqlInstance.DataSourceVolcengineRdsMssqlInstances(),
"volcengine_rds_mssql_backups": mssqlBackup.DataSourceVolcengineRdsMssqlBackups(),
},
ResourcesMap: map[string]*schema.Resource{
"volcengine_vpc": vpc.ResourceVolcengineVpc(),
Expand Down Expand Up @@ -767,6 +778,10 @@ func Provider() terraform.ResourceProvider {
"volcengine_cloud_monitor_contact_group": cloud_monitor_contact_group.ResourceVolcengineCloudMonitorContactGroup(),
"volcengine_cloud_monitor_event_rule": cloud_monitor_event_rule.ResourceVolcengineCloudMonitorEventRule(),
"volcengine_cloud_monitor_rule": cloud_monitor_rule.ResourceVolcengineCloudMonitorRule(),

// ================ RdsMssql ================
"volcengine_rds_mssql_instance": mssqlInstance.ResourceVolcengineRdsMssqlInstance(),
"volcengine_rds_mssql_backup": mssqlBackup.ResourceVolcengineRdsMssqlBackup(),
},
ConfigureFunc: ProviderConfigure,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
package sqlserver_backup

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

func DataSourceVolcengineRdsMssqlBackups() *schema.Resource {
return &schema.Resource{
Read: dataSourceVolcengineMssqlBackupsRead,
Schema: map[string]*schema.Schema{
"instance_id": {
Type: schema.TypeString,
Required: true,
Description: "The id of the instance.",
},
"backup_id": {
Type: schema.TypeString,
Optional: true,
Description: "The id of the backup.",
},
"backup_start_time": {
Type: schema.TypeString,
Optional: true,
Description: "The start time of the backup.",
},
"backup_end_time": {
Type: schema.TypeString,
Optional: true,
Description: "The end time of the backup.",
},
"backup_type": {
Type: schema.TypeString,
Optional: true,
Description: "The type of the backup.",
},
"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 query.",
},
"backups": {
Description: "The collection of query.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the backup.",
},
"backup_id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the backup.",
},
"backup_start_time": {
Type: schema.TypeString,
Computed: true,
Description: "The start time of the backup.",
},
"backup_end_time": {
Type: schema.TypeString,
Computed: true,
Description: "The end time of the backup.",
},
"backup_type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of the backup.",
},
"backup_file_size": {
Type: schema.TypeInt,
Computed: true,
Description: "The size of the backup file.",
},
"backup_method": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the backup method.",
},
"backup_status": {
Type: schema.TypeString,
Computed: true,
Description: "The status of the backup.",
},
"create_type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of the backup create.",
},
"backup_database_detail": {
Type: schema.TypeList,
Computed: true,
Description: "The detail of the database.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backup_start_time": {
Type: schema.TypeString,
Computed: true,
Description: "The start time of the backup.",
},
"backup_end_time": {
Type: schema.TypeString,
Computed: true,
Description: "The end time of the backup.",
},
"backup_type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of the backup.",
},
"backup_file_size": {
Type: schema.TypeInt,
Computed: true,
Description: "The size of the backup file.",
},
"backup_file_name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the backup file.",
},
"database_name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the database.",
},
"backup_download_link_inner": {
Type: schema.TypeString,
Computed: true,
Description: "Intranet backup download link.",
},
"backup_download_link_eip": {
Type: schema.TypeString,
Computed: true,
Description: "External backup download link.",
},
"link_expired_time": {
Type: schema.TypeString,
Computed: true,
Description: "Download link expiration time.",
},
"download_progress": {
Type: schema.TypeInt,
Computed: true,
Description: "Backup file preparation progress, unit: %.",
},
"download_status": {
Type: schema.TypeString,
Computed: true,
Description: "Download status.",
},
},
},
},
},
},
},
},
}
}

func dataSourceVolcengineMssqlBackupsRead(d *schema.ResourceData, meta interface{}) error {
service := NewRdsMssqlBackupService(meta.(*ve.SdkClient))
return service.Dispatcher.Data(service, d, DataSourceVolcengineRdsMssqlBackups())
}
Loading

0 comments on commit 993845d

Please sign in to comment.