Skip to content

Commit

Permalink
Merge pull request #172 from volcengine/Feat/private-zone
Browse files Browse the repository at this point in the history
Feat/private zone
  • Loading branch information
msq177 committed Aug 9, 2024
2 parents 6aeb3f1 + 2951e2b commit ff364fa
Show file tree
Hide file tree
Showing 47 changed files with 4,363 additions and 32 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.149"
TerraformProviderVersion = "0.0.150"
)
1 change: 1 addition & 0 deletions docgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ var resourceKeys = map[string]string{
"financial_relation": "FINANCIAL_RELATION",
"cloud_identity": "CLOUD_IDENTITY",
"kafka": "KAFKA",
"private_zone": "PRIVATE_ZONE",
}

type Products struct {
Expand Down
3 changes: 3 additions & 0 deletions example/dataPrivateZoneRecordSets/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "volcengine_private_zone_record_sets" "foo" {
zid = 245****
}
4 changes: 4 additions & 0 deletions example/dataPrivateZoneRecords/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "volcengine_private_zone_records" "foo" {
zid = 245****
record_id = "907925684878276****"
}
1 change: 1 addition & 0 deletions example/dataPrivateZoneResolverEndpoints/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data "volcengine_private_zone_resolver_endpoints" "foo" {}
1 change: 1 addition & 0 deletions example/dataPrivateZoneResolverRules/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data "volcengine_private_zone_resolver_rules" "foo" {}
7 changes: 7 additions & 0 deletions example/dataPrivateZones/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "volcengine_private_zones" "foo" {
zid = 77****
zone_name = "volces.com"
search_mode = "EXACT"
recursion_mode = true
line_mode = 3
}
14 changes: 14 additions & 0 deletions example/privateZone/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "volcengine_private_zone" "foo" {
zone_name = "acc-test-pz.com"
remark = "acc-test-new"
recursion_mode = true
intelligent_mode = true
load_balance_mode = true
vpcs {
vpc_id = "vpc-rs4mi0jedipsv0x57pf****"
}
vpcs {
vpc_id = "vpc-3qdzk9xju6o747prml0jk****"
region = "cn-shanghai"
}
}
22 changes: 22 additions & 0 deletions example/privateZoneRecord/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "volcengine_private_zone_record" "foo" {
zid = 245****
host = "www"
type = "A"
value = "10.1.1.158"
weight = 8
ttl = 700
remark = "tf-test"
enable = true
}

data "volcengine_private_zone_record_sets" "foo" {
zid = volcengine_private_zone_record.foo.zid
host = volcengine_private_zone_record.foo.host
search_mode = "EXACT"
}

resource "volcengine_private_zone_record_weight_enabler" "foo" {
zid = volcengine_private_zone_record.foo.zid
record_set_id = [for set in data.volcengine_private_zone_record_sets.foo.record_sets : set.record_set_id if set.type == volcengine_private_zone_record.foo.type][0]
weight_enabled = true
}
22 changes: 22 additions & 0 deletions example/privateZoneRecordWeightEnabler/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "volcengine_private_zone_record" "foo" {
zid = 245****
host = "www"
type = "A"
value = "10.1.1.158"
weight = 8
ttl = 700
remark = "tf-test"
enable = true
}

data "volcengine_private_zone_record_sets" "foo" {
zid = volcengine_private_zone_record.foo.zid
host = volcengine_private_zone_record.foo.host
search_mode = "EXACT"
}

resource "volcengine_private_zone_record_weight_enabler" "foo" {
zid = volcengine_private_zone_record.foo.zid
record_set_id = [for set in data.volcengine_private_zone_record_sets.foo.record_sets : set.record_set_id if set.type == volcengine_private_zone_record.foo.type][0]
weight_enabled = true
}
26 changes: 26 additions & 0 deletions example/privateZoneResolverEndpoint/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "volcengine_private_zone_resolver_endpoint" "foo" {
name = "tf-test"
vpc_id = "vpc-13f9uuuqfdjb43n6nu5p1****"
vpc_region = "cn-beijing"
security_group_id = "sg-mj2nsckay29s5smt1b0d****"
ip_configs {
az_id = "cn-beijing-a"
subnet_id = "subnet-mj2o4co2m2v45smt1bx1****"
ip = "172.16.0.2"
}
ip_configs {
az_id = "cn-beijing-a"
subnet_id = "subnet-mj2o4co2m2v45smt1bx1****"
ip = "172.16.0.3"
}
ip_configs {
az_id = "cn-beijing-a"
subnet_id = "subnet-mj2o4co2m2v45smt1bx1****"
ip = "172.16.0.4"
}
ip_configs {
az_id = "cn-beijing-a"
subnet_id = "subnet-mj2o4co2m2v45smt1bx1****"
ip = "172.16.0.5"
}
}
14 changes: 14 additions & 0 deletions example/privateZoneResolverRule/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "volcengine_private_zone_resolver_rule" "foo" {
endpoint_id = 346
name = "tf0"
type = "OUTBOUND"
vpcs {
region = "cn-beijing"
vpc_id = "vpc-13f9uuuqfdjb43n6nu5p1****"
}
forward_ips {
ip = "10.199.38.19"
port = 33
}
zone_name = ["www.baidu.com"]
}
3 changes: 3 additions & 0 deletions example/privateZoneUserVpcAuthorization/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "volcengine_private_zone_user_vpc_authorization" "foo" {
account_id = "2100278462"
}
18 changes: 9 additions & 9 deletions example/vkeNodePool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ resource "volcengine_vke_node_pool" "foo1" {
instance_type_ids = ["ecs.g1ie.xlarge"]
subnet_ids = [volcengine_subnet.foo.id]
image_id = [for image in data.volcengine_images.foo.images : image.image_id if image.image_name == "veLinux 1.0 CentOS兼容版 64位"][0]
system_volume {
type = "ESSD_PL0"
size = "50"
}
data_volumes {
type = "ESSD_PL0"
size = "50"
mount_point = "/tf"
}
system_volume {
type = "ESSD_PL0"
size = 50
}
data_volumes {
type = "ESSD_PL0"
size = 50
mount_point = "/tf1"
}
initialize_script = "ZWNobyBoZWxsbyB0ZXJyYWZvcm0h"
security {
login {
Expand Down
33 changes: 14 additions & 19 deletions volcengine/ebs/volume/resource_volcengine_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

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

Expand Down Expand Up @@ -45,24 +44,21 @@ func ResourceVolcengineVolume() *schema.Resource {
Description: "The name of Volume.",
},
"volume_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The type of Volume, the value is `PTSSD` or `ESSD_PL0` or `ESSD_PL1` or `ESSD_PL2` or `ESSD_FlexPL`.",
ValidateFunc: validation.StringInSlice([]string{"ESSD_PL0", "ESSD_PL1", "ESSD_PL2", "PTSSD", "ESSD_FlexPL"}, false),
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The type of Volume, the value is `PTSSD` or `ESSD_PL0` or `ESSD_PL1` or `ESSD_PL2` or `ESSD_FlexPL`.",
},
"kind": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"data"}, false),
Description: "The kind of Volume, the value is `data`.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The kind of Volume, the value is `data`.",
},
"size": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(20), // 最小20GB
Description: "The size of Volume.",
Type: schema.TypeInt,
Required: true,
Description: "The size of Volume.",
},
"description": {
Type: schema.TypeString,
Expand All @@ -79,10 +75,9 @@ func ResourceVolcengineVolume() *schema.Resource {
"When use this field to attach ecs instance, the attached volume cannot be deleted by terraform, please use `terraform state rm volcengine_volume.resource_name` command to remove it from terraform state file and management.",
},
"volume_charge_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"PostPaid", "PrePaid"}, false),
Default: "PostPaid",
Type: schema.TypeString,
Optional: true,
Default: "PostPaid",
Description: "The charge type of the Volume, the value is `PostPaid` or `PrePaid`. " +
"The `PrePaid` volume cannot be detached. " +
"Please note that `PrePaid` type needs to ask the system administrator to apply for a whitelist.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package private_zone

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 DataSourceVolcenginePrivateZones() *schema.Resource {
return &schema.Resource{
Read: dataSourceVolcenginePrivateZonesRead,
Schema: map[string]*schema.Schema{
"zid": {
Type: schema.TypeInt,
Optional: true,
Description: "The zid of Private Zone.",
},
"zone_name": {
Type: schema.TypeString,
Optional: true,
Description: "The name of Private Zone.",
},
"region": {
Type: schema.TypeString,
Optional: true,
Description: "The region of Private Zone.",
},
"vpc_id": {
Type: schema.TypeString,
Optional: true,
Description: "The vpc id associated to Private Zone.",
},
"recursion_mode": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether the recursion mode of Private Zone is enabled.",
},
"line_mode": {
Type: schema.TypeInt,
Optional: true,
Description: "The line mode of Private Zone, specified whether the intelligent mode and the load balance function is enabled.",
},
"search_mode": {
Type: schema.TypeString,
Optional: true,
Default: "LIKE",
ValidateFunc: validation.StringInSlice([]string{"LIKE", "EXACT"}, false),
Description: "The search mode of query. Valid values: `LIKE`, `EXACT`. Default is `LIKE`.",
},

"name_regex": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringIsValidRegExp,
Description: "A Name Regex of Resource.",
},
"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.",
},
"private_zones": {
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 private zone.",
},
"zid": {
Type: schema.TypeInt,
Computed: true,
Description: "The id of the private zone.",
},
"zone_name": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the private zone.",
},
"remark": {
Type: schema.TypeString,
Computed: true,
Description: "The remark of the private zone.",
},
"record_count": {
Type: schema.TypeInt,
Computed: true,
Description: "The record count of the private zone.",
},
"recursion_mode": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether the recursion mode of the private zone is enabled.",
},
"line_mode": {
Type: schema.TypeInt,
Computed: true,
Description: "The line mode of the private zone, specified whether the intelligent mode and the load balance function is enabled.",
},
"last_operator": {
Type: schema.TypeString,
Computed: true,
Description: "The account id of the last operator who created the private zone.",
},
"created_at": {
Type: schema.TypeString,
Computed: true,
Description: "The created time of the private zone.",
},
"updated_at": {
Type: schema.TypeString,
Computed: true,
Description: "The updated time of the private zone.",
},
"region": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The region of the private zone.",
},
"bind_vpcs": {
Type: schema.TypeList,
Computed: true,
Description: "The Bind vpc info of the private zone.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The id of the bind vpc.",
},
"region": {
Type: schema.TypeString,
Computed: true,
Description: "The region of the bind vpc.",
},
"region_name": {
Type: schema.TypeString,
Computed: true,
Description: "The region name of the bind vpc.",
},
"account_id": {
Type: schema.TypeString,
Computed: true,
Description: "The account id of the bind vpc.",
},
},
},
},
},
},
},
},
}
}

func dataSourceVolcenginePrivateZonesRead(d *schema.ResourceData, meta interface{}) error {
service := NewPrivateZoneService(meta.(*ve.SdkClient))
return service.Dispatcher.Data(service, d, DataSourceVolcenginePrivateZones())
}
Loading

0 comments on commit ff364fa

Please sign in to comment.