Skip to content

Commit 1213141

Browse files
lsy1968shanye997
authored andcommitted
DDoS port access configuration
1 parent 2016136 commit 1213141

File tree

3 files changed

+196
-0
lines changed

3 files changed

+196
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Introduction
2+
3+
<!-- DOCS_DESCRIPTION_CN -->
4+
本示例用于在阿里云上配置DDoS高防端口接入,涉及到DDoS高防实例的端口配置管理。
5+
详情可查看[通过Terraform配置DDoS高防端口接入](http://help.aliyun.com/document_detail/2527859.htm)
6+
<!-- DOCS_DESCRIPTION_CN -->
7+
8+
<!-- DOCS_DESCRIPTION_EN -->
9+
This example is used to add a port to Anti-DDoS Pro or Anti-DDoS Premium on Alibaba Cloud, which involves the management of port configuration of Anti-DDoS instance.
10+
More details in [Add a port to Anti-DDoS Pro or Anti-DDoS Premium](http://help.aliyun.com/document_detail/2527859.htm).
11+
<!-- DOCS_DESCRIPTION_EN -->
12+
13+
<!-- BEGIN_TF_DOCS -->
14+
## Providers
15+
16+
| Name | Version |
17+
|------|---------|
18+
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a |
19+
20+
## Modules
21+
22+
No modules.
23+
24+
## Resources
25+
26+
| Name | Type |
27+
|------|------|
28+
| [alicloud_ddoscoo_instance.newInstance](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/ddoscoo_instance) | resource |
29+
| [alicloud_ddoscoo_port.default](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/ddoscoo_port) | resource |
30+
31+
## Inputs
32+
33+
| Name | Description | Type | Default | Required |
34+
|------|-------------|------|---------|:--------:|
35+
| <a name="input_backend_port"></a> [backend\_port](#input\_backend\_port) | The backend port for the DDoS CoO port | `string` | `"7001"` | no |
36+
| <a name="input_bandwidth"></a> [bandwidth](#input\_bandwidth) | Bandwidth of the DDoS CoO instance | `string` | `"40"` | no |
37+
| <a name="input_base_bandwidth"></a> [base\_bandwidth](#input\_base\_bandwidth) | Base bandwidth of the DDoS CoO instance | `string` | `"30"` | no |
38+
| <a name="input_ddoscoo_instance_name"></a> [ddoscoo\_instance\_name](#input\_ddoscoo\_instance\_name) | The name of the DDoS CoO instance | `string` | `"Ddoscootest"` | no |
39+
| <a name="input_domain_count"></a> [domain\_count](#input\_domain\_count) | Number of domains for the DDoS CoO instance | `string` | `"50"` | no |
40+
| <a name="input_frontend_port"></a> [frontend\_port](#input\_frontend\_port) | The frontend port for the DDoS CoO port | `string` | `"7001"` | no |
41+
| <a name="input_frontend_protocol"></a> [frontend\_protocol](#input\_frontend\_protocol) | The frontend protocol for the DDoS CoO port | `string` | `"tcp"` | no |
42+
| <a name="input_period"></a> [period](#input\_period) | Purchase period of the DDoS CoO instance | `string` | `"1"` | no |
43+
| <a name="input_port_count"></a> [port\_count](#input\_port\_count) | Number of ports for the DDoS CoO instance | `string` | `"50"` | no |
44+
| <a name="input_pricing_mode"></a> [pricing\_mode](#input\_pricing\_mode) | Pricing mode of the DDoS CoO instance (Prepaid or Postpaid) | `string` | `"Postpaid"` | no |
45+
| <a name="input_product_type"></a> [product\_type](#input\_product\_type) | Product type of the DDoS CoO instance | `string` | `"ddoscoo"` | no |
46+
| <a name="input_real_servers"></a> [real\_servers](#input\_real\_servers) | The list of real servers for the DDoS CoO port | `list(string)` | <pre>[<br/> "196.128.10.21",<br/> "196.129.10.11"<br/>]</pre> | no |
47+
| <a name="input_region_id"></a> [region\_id](#input\_region\_id) | n/a | `string` | `"cn-hangzhou"` | no |
48+
| <a name="input_service_bandwidth"></a> [service\_bandwidth](#input\_service\_bandwidth) | Service bandwidth of the DDoS CoO instance | `string` | `"100"` | no |
49+
<!-- END_TF_DOCS -->
50+
51+
## Documentation
52+
<!-- docs-link -->
53+
54+
The template is based on Aliyun document: [DDoS port access configuration](http://help.aliyun.com/document_detail/2527859.htm)
55+
56+
<!-- docs-link -->
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
variable "region_id" {
2+
type = string
3+
default = "cn-hangzhou"
4+
}
5+
6+
# DDoS CoO 实例名称
7+
variable "ddoscoo_instance_name" {
8+
description = "The name of the DDoS CoO instance"
9+
type = string
10+
default = "Ddoscootest" # 默认值
11+
}
12+
13+
# 基础带宽
14+
variable "base_bandwidth" {
15+
description = "Base bandwidth of the DDoS CoO instance"
16+
type = string
17+
default = "30" # 默认值
18+
}
19+
20+
# 带宽
21+
variable "bandwidth" {
22+
description = "Bandwidth of the DDoS CoO instance"
23+
type = string
24+
default = "40" # 默认值
25+
}
26+
27+
# 服务带宽
28+
variable "service_bandwidth" {
29+
description = "Service bandwidth of the DDoS CoO instance"
30+
type = string
31+
default = "100" # 默认值
32+
}
33+
34+
# 端口数量
35+
variable "port_count" {
36+
description = "Number of ports for the DDoS CoO instance"
37+
type = string
38+
default = "50" # 默认值
39+
}
40+
41+
# 域名数量
42+
variable "domain_count" {
43+
description = "Number of domains for the DDoS CoO instance"
44+
type = string
45+
default = "50" # 默认值
46+
}
47+
48+
# 购买周期
49+
variable "period" {
50+
description = "Purchase period of the DDoS CoO instance"
51+
type = string
52+
default = "1" # 默认值
53+
}
54+
55+
# 产品类型
56+
variable "product_type" {
57+
description = "Product type of the DDoS CoO instance"
58+
type = string
59+
default = "ddoscoo" # 默认值
60+
}
61+
62+
# 计费模式
63+
variable "pricing_mode" {
64+
description = "Pricing mode of the DDoS CoO instance (Prepaid or Postpaid)"
65+
type = string
66+
default = "Postpaid" # 默认值
67+
}
68+
69+
# 前端端口
70+
variable "frontend_port" {
71+
description = "The frontend port for the DDoS CoO port"
72+
type = string
73+
default = "7001"
74+
}
75+
76+
# 后端端口
77+
variable "backend_port" {
78+
description = "The backend port for the DDoS CoO port"
79+
type = string
80+
default = "7001"
81+
}
82+
83+
# 前端协议
84+
variable "frontend_protocol" {
85+
description = "The frontend protocol for the DDoS CoO port"
86+
type = string
87+
default = "tcp"
88+
}
89+
90+
# 实际服务器列表
91+
variable "real_servers" {
92+
description = "The list of real servers for the DDoS CoO port"
93+
type = list(string)
94+
default = ["196.128.10.21", "196.129.10.11"]
95+
}
96+
97+
provider "alicloud" {
98+
region = var.region_id
99+
}
100+
101+
resource "alicloud_ddoscoo_instance" "newInstance" {
102+
name = var.ddoscoo_instance_name
103+
base_bandwidth = var.base_bandwidth
104+
bandwidth = var.bandwidth
105+
service_bandwidth = var.service_bandwidth
106+
port_count = var.port_count
107+
domain_count = var.domain_count
108+
period = var.pricing_mode == "Prepaid" ? var.period : null
109+
product_type = var.product_type
110+
}
111+
112+
resource "alicloud_ddoscoo_port" "default" {
113+
instance_id = alicloud_ddoscoo_instance.newInstance.id
114+
frontend_port = var.frontend_port
115+
backend_port = var.backend_port
116+
frontend_protocol = var.frontend_protocol
117+
real_servers = var.real_servers
118+
}
119+
120+
output "instance_id" {
121+
description = "The ID of the DDoS CoO instance"
122+
value = alicloud_ddoscoo_instance.newInstance.id
123+
}
124+
125+
output "instance_name" {
126+
description = "The name of the DDoS CoO instance"
127+
value = var.ddoscoo_instance_name
128+
}
129+
130+
output "port_id" {
131+
description = "The ID of the DDoS CoO port"
132+
value = alicloud_ddoscoo_port.default.id
133+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
terraform {
2+
required_providers {
3+
alicloud = {
4+
source = "aliyun/alicloud"
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)