Skip to content

Commit f3fa5b2

Browse files
lsy1968shanye997
authored andcommitted
201-use-case-cdn-accelerate-resource-from-ecs
1 parent 91de764 commit f3fa5b2

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

quickstarts/CDN/201-use-case-cdn-accelerate-resource-from-ecs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ No modules.
3030
| [alicloud_cdn_domain_new.example](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/cdn_domain_new) | resource |
3131
| [alicloud_instance.instance](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/instance) | resource |
3232
| [alicloud_security_group.group](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/security_group) | resource |
33-
| [alicloud_security_group_rule.egress](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/security_group_rule) | resource |
33+
| [alicloud_security_group_rule.ingress](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/security_group_rule) | resource |
3434
| [alicloud_vpc.vpc](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vpc) | resource |
3535
| [alicloud_vswitch.vswitch](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vswitch) | resource |
3636
| [random_integer.default](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) | resource |
@@ -41,9 +41,9 @@ No modules.
4141
| Name | Description | Type | Default | Required |
4242
|------|-------------|------|---------|:--------:|
4343
| <a name="input_creater_ecs"></a> [creater\_ecs](#input\_creater\_ecs) | Do you want to create a ECS instance | `bool` | `true` | no |
44-
| <a name="input_domain_home"></a> [domain\_home](#input\_domain\_home) | your domain name | `string` | `"tf-example.com"` | no |
44+
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | your domain name | `string` | `"tf-example.com"` | no |
4545
| <a name="input_existed_ecs_ip"></a> [existed\_ecs\_ip](#input\_existed\_ecs\_ip) | The ip of your existed ecs | `string` | `""` | no |
46-
| <a name="input_host_record"></a> [host\_record](#input\_host\_record) | Host Record,like image | `string` | `"image"` | no |
46+
| <a name="input_host_name"></a> [host\_name](#input\_host\_name) | Host Record,like image | `string` | `"image"` | no |
4747
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `"cn-beijing"` | no |
4848
<!-- END_TF_DOCS -->
4949

quickstarts/CDN/201-use-case-cdn-accelerate-resource-from-ecs/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ variable "region" {
33
}
44

55
# 域名(改为您的域名)
6-
variable "domain_home" {
6+
variable "domain_name" {
77
default = "tf-example.com"
88
description = "your domain name"
99
}
1010

1111
# 主机记录
12-
variable "host_record" {
12+
variable "host_name" {
1313
type = string
1414
default = "image"
1515
description = "Host Record,like image"
@@ -65,14 +65,14 @@ resource "alicloud_security_group" "group" {
6565
vpc_id = alicloud_vpc.vpc.0.id
6666
}
6767

68-
# 添加允许TCP 80端口出方向流量的规则
69-
resource "alicloud_security_group_rule" "egress" {
68+
# 添加允许TCP 80端口入方向流量的规则
69+
resource "alicloud_security_group_rule" "ingress" {
7070
count = var.creater_ecs ? 1 : 0
71-
type = "egress" # 出方向规则
71+
type = "ingress" # 入方向规则
7272
ip_protocol = "tcp" # TCP协议
7373
nic_type = "intranet" # 内网网卡类型(VPC环境)
7474
policy = "accept" # 允许策略
75-
port_range = "8/80" # 允许80端口
75+
port_range = "80/80" # 允许80端口
7676
priority = 1 # 优先级设置
7777
security_group_id = alicloud_security_group.group.0.id # 关联的安全组ID
7878
cidr_ip = "10.0.0.0/8" # 允许的IP地址范围,示例为10.0.0.0/8
@@ -105,7 +105,7 @@ resource "alicloud_instance" "instance" {
105105

106106
# 添加一个加速域名
107107
resource "alicloud_cdn_domain_new" "example" {
108-
domain_name = var.domain_home
108+
domain_name = format("%s.%s", var.host_name, var.domain_name)
109109
cdn_type = "web"
110110
scope = "overseas"
111111
sources {
@@ -118,9 +118,9 @@ resource "alicloud_cdn_domain_new" "example" {
118118

119119
# 域名解析
120120
resource "alicloud_alidns_record" "example" {
121-
domain_name = var.domain_home
121+
domain_name = var.domain_name
122122
type = "CNAME"
123-
rr = var.host_record
123+
rr = var.host_name
124124
value = alicloud_cdn_domain_new.example.cname
125125
ttl = 600
126126
}

0 commit comments

Comments
 (0)