|
| 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 | +} |
0 commit comments