@@ -3,13 +3,13 @@ variable "region" {
3
3
}
4
4
5
5
# 域名(改为您的域名)
6
- variable "domain_home " {
6
+ variable "domain_name " {
7
7
default = " tf-example.com"
8
8
description = " your domain name"
9
9
}
10
10
11
11
# 主机记录
12
- variable "host_record " {
12
+ variable "host_name " {
13
13
type = string
14
14
default = " image"
15
15
description = " Host Record,like image"
@@ -65,14 +65,14 @@ resource "alicloud_security_group" "group" {
65
65
vpc_id = alicloud_vpc. vpc . 0 . id
66
66
}
67
67
68
- # 添加允许TCP 80端口出方向流量的规则
69
- resource "alicloud_security_group_rule" "egress " {
68
+ # 添加允许TCP 80端口入方向流量的规则
69
+ resource "alicloud_security_group_rule" "ingress " {
70
70
count = var. creater_ecs ? 1 : 0
71
- type = " egress " # 出方向规则
71
+ type = " ingress " # 入方向规则
72
72
ip_protocol = " tcp" # TCP协议
73
73
nic_type = " intranet" # 内网网卡类型(VPC环境)
74
74
policy = " accept" # 允许策略
75
- port_range = " 8 /80" # 允许80端口
75
+ port_range = " 80 /80" # 允许80端口
76
76
priority = 1 # 优先级设置
77
77
security_group_id = alicloud_security_group. group . 0 . id # 关联的安全组ID
78
78
cidr_ip = " 10.0.0.0/8" # 允许的IP地址范围,示例为10.0.0.0/8
@@ -105,7 +105,7 @@ resource "alicloud_instance" "instance" {
105
105
106
106
# 添加一个加速域名
107
107
resource "alicloud_cdn_domain_new" "example" {
108
- domain_name = var. domain_home
108
+ domain_name = format ( " %s.%s " , var. host_name , var . domain_name )
109
109
cdn_type = " web"
110
110
scope = " overseas"
111
111
sources {
@@ -118,9 +118,9 @@ resource "alicloud_cdn_domain_new" "example" {
118
118
119
119
# 域名解析
120
120
resource "alicloud_alidns_record" "example" {
121
- domain_name = var. domain_home
121
+ domain_name = var. domain_name
122
122
type = " CNAME"
123
- rr = var. host_record
123
+ rr = var. host_name
124
124
value = alicloud_cdn_domain_new. example . cname
125
125
ttl = 600
126
126
}
0 commit comments