Skip to content

Commit

Permalink
Merge pull request #114 from volcengine/feat/nat
Browse files Browse the repository at this point in the history
Feat/nat
  • Loading branch information
zpp12354321 authored Aug 15, 2023
2 parents 0093eed + c894173 commit 46d74c4
Show file tree
Hide file tree
Showing 106 changed files with 7,413 additions and 297 deletions.
1 change: 1 addition & 0 deletions common/common_volcengine_bypass_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (u *BypassSvc) DoBypassSvcCall(info BypassSvcInfo, input *map[string]interf
if info.ContentPath != "" && (op.HTTPMethod == "PUT" || op.HTTPMethod == "POST") {
content, _ = os.Open(info.ContentPath)
req.Body = content
req.ResetBody()
req.HTTPRequest.Header.Set("Content-Length", strconv.FormatInt(u.tryResolveLength(content), 10))
}

Expand Down
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.96"
TerraformProviderVersion = "0.0.97"
)
4 changes: 2 additions & 2 deletions example/customerGateway/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "volcengine_customer_gateway" "foo" {
ip_address = "192.0.1.3"
customer_gateway_name = "tf-test"
description = "tf-test"
customer_gateway_name = "acc-test"
description = "acc-test"
project_name = "default"
}
10 changes: 8 additions & 2 deletions example/dataCustomerGateways/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
data "volcengine_customer_gateways" "foo" {
ids = ["cgw-2d68c4zglycjk58ozfe96norh"]
resource "volcengine_customer_gateway" "foo" {
ip_address = "192.0.1.3"
customer_gateway_name = "acc-test"
description = "acc-test"
project_name = "default"
}
data "volcengine_customer_gateways" "foo"{
ids = [volcengine_customer_gateway.foo.id]
}
59 changes: 57 additions & 2 deletions example/dataDnatEntries/main.tf
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
data "volcengine_dnat_entries" "default" {
}
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_nat_gateway" "foo" {
vpc_id = volcengine_vpc.foo.id
subnet_id = volcengine_subnet.foo.id
spec = "Small"
nat_gateway_name = "acc-test-ng"
description = "acc-test"
billing_type = "PostPaid"
project_name = "default"
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_eip_address" "foo" {
name = "acc-test-eip"
description = "acc-test"
bandwidth = 1
billing_type = "PostPaidByBandwidth"
isp = "BGP"
}

resource "volcengine_eip_associate" "foo" {
allocation_id = volcengine_eip_address.foo.id
instance_id = volcengine_nat_gateway.foo.id
instance_type = "Nat"
}

resource "volcengine_dnat_entry" "foo" {
dnat_entry_name = "acc-test-dnat-entry"
external_ip = volcengine_eip_address.foo.eip_address
external_port = 80
internal_ip = "172.16.0.10"
internal_port = 80
nat_gateway_id = volcengine_nat_gateway.foo.id
protocol = "tcp"
depends_on = [volcengine_eip_associate.foo]
}

data "volcengine_dnat_entries" "foo"{
ids = [volcengine_dnat_entry.foo.id]
}
36 changes: 33 additions & 3 deletions example/dataNatGateways/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
data "volcengine_nat_gateways" "default" {
ids = ["ngw-2743w1f6iqby87fap8tvm9kop", "ngw-274gwbqe340zk7fap8spkzo7x"]
}
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_nat_gateway" "foo" {
vpc_id = volcengine_vpc.foo.id
subnet_id = volcengine_subnet.foo.id
spec = "Small"
nat_gateway_name = "acc-test-ng-${count.index}"
description = "acc-test"
billing_type = "PostPaid"
project_name = "default"
tags {
key = "k1"
value = "v1"
}
count =3
}

data "volcengine_nat_gateways" "foo"{
ids = volcengine_nat_gateway.foo[*].id
}
105 changes: 103 additions & 2 deletions example/dataScalingActivities/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,104 @@
data "volcengine_scaling_activities" "default"{
scaling_group_id = "scg-ybqm0b6kcigh9zu9ce6t"
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_security_group" "foo" {
security_group_name = "acc-test-security-group"
vpc_id = volcengine_vpc.foo.id
}


data "volcengine_images" "foo" {
os_type = "Linux"
visibility = "public"
instance_type_id = "ecs.g1.large"
}

resource "volcengine_ecs_key_pair" "foo" {
description = "acc-test-2"
key_pair_name = "acc-test-key-pair-name"
}

resource "volcengine_ecs_launch_template" "foo" {
description = "acc-test-desc"
eip_bandwidth = 200
eip_billing_type = "PostPaidByBandwidth"
eip_isp = "BGP"
host_name = "acc-hostname"
image_id = data.volcengine_images.foo.images[0].image_id
instance_charge_type = "PostPaid"
instance_name = "acc-instance-name"
instance_type_id = "ecs.g1.large"
key_pair_name = volcengine_ecs_key_pair.foo.key_pair_name
launch_template_name = "acc-test-template"
network_interfaces {
subnet_id = volcengine_subnet.foo.id
security_group_ids = [volcengine_security_group.foo.id]
}
volumes {
volume_type = "ESSD_PL0"
size = 50
delete_with_instance = true
}
}

resource "volcengine_scaling_group" "foo" {
scaling_group_name = "acc-test-scaling-group"
subnet_ids = [volcengine_subnet.foo.id]
multi_az_policy = "BALANCE"
desire_instance_number = -1
min_instance_number = 0
max_instance_number = 10
instance_terminate_policy = "OldestInstance"
default_cooldown = 10
launch_template_id = volcengine_ecs_launch_template.foo.id
launch_template_version = "Default"
}

resource "volcengine_scaling_group_enabler" "foo" {
scaling_group_id = volcengine_scaling_group.foo.id
}

resource "volcengine_ecs_instance" "foo" {
count = 3
instance_name = "acc-test-ecs-${count.index}"
description = "acc-test"
host_name = "tf-acc-test"
image_id = data.volcengine_images.foo.images[0].image_id
instance_type = "ecs.g1.large"
password = "93f0cb0614Aab12"
instance_charge_type = "PostPaid"
system_volume_type = "ESSD_PL0"
system_volume_size = 40
subnet_id = volcengine_subnet.foo.id
security_group_ids = [volcengine_security_group.foo.id]
}

resource "volcengine_scaling_instance_attachment" "foo" {
count = length(volcengine_ecs_instance.foo)
instance_id = volcengine_ecs_instance.foo[count.index].id
scaling_group_id = volcengine_scaling_group.foo.id
entrusted = true

depends_on = [
volcengine_scaling_group_enabler.foo
]
}

data "volcengine_scaling_activities" "foo" {
scaling_group_id = volcengine_scaling_group.foo.id
depends_on = [
volcengine_scaling_instance_attachment.foo
]
}
57 changes: 55 additions & 2 deletions example/dataScalingConfigurations/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
data "volcengine_scaling_configurations" "default"{
ids = ["scc-ybrurj4uw6gh9zecj327"]
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_security_group" "foo" {
security_group_name = "acc-test-security-group"
vpc_id = volcengine_vpc.foo.id
}

data "volcengine_images" "foo" {
os_type = "Linux"
visibility = "public"
instance_type_id = "ecs.g1.large"
}

resource "volcengine_scaling_group" "foo" {
scaling_group_name = "acc-test-scaling-group"
subnet_ids = [volcengine_subnet.foo.id]
multi_az_policy = "BALANCE"
desire_instance_number = 0
min_instance_number = 0
max_instance_number = 1
instance_terminate_policy = "OldestInstance"
default_cooldown = 10
}

resource "volcengine_scaling_configuration" "foo" {
count = 3
image_id = data.volcengine_images.foo.images[0].image_id
instance_name = "acc-test-instance"
instance_types = ["ecs.g1.large"]
password = "93f0cb0614Aab12"
scaling_configuration_name = "acc-test-scaling-config-${count.index}"
scaling_group_id = volcengine_scaling_group.foo.id
security_group_ids = [volcengine_security_group.foo.id]
volumes {
volume_type = "ESSD_PL0"
size = 50
delete_with_instance = true
}
}

data "volcengine_scaling_configurations" "foo" {
ids = volcengine_scaling_configuration.foo[*].id
}
41 changes: 39 additions & 2 deletions example/dataScalingGroups/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
data "volcengine_scaling_groups" "default"{
ids = ["scg-ybru8pazhgl8j1di4tyd"]
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_scaling_group" "foo" {
count = 3
scaling_group_name = "acc-test-scaling-group-${count.index}"
subnet_ids = [volcengine_subnet.foo.id]
multi_az_policy = "BALANCE"
desire_instance_number = 0
min_instance_number = 0
max_instance_number = 10
instance_terminate_policy = "OldestInstance"
default_cooldown = 30

tags {
key = "k2"
value = "v2"
}

tags {
key = "k1"
value = "v1"
}
}

data "volcengine_scaling_groups" "default" {
ids = volcengine_scaling_group.foo[*].id
}
Loading

0 comments on commit 46d74c4

Please sign in to comment.