Skip to content

Commit cd7c4cc

Browse files
committed
Configure CDN domain name
1 parent 64d696f commit cd7c4cc

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Providers
3+
4+
| Name | Version |
5+
|------|---------|
6+
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a |
7+
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
8+
9+
## Modules
10+
11+
No modules.
12+
13+
## Resources
14+
15+
| Name | Type |
16+
|------|------|
17+
| [alicloud_cdn_domain_config.config-ip](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/cdn_domain_config) | resource |
18+
| [alicloud_cdn_domain_new.domain](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/cdn_domain_new) | resource |
19+
| [random_integer.default](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) | resource |
20+
21+
## Inputs
22+
23+
No inputs.
24+
<!-- END_TF_DOCS -->
25+
## Documentation
26+
<!-- docs-link -->
27+
28+
The template is based on Aliyun document: [Configure CDN domain name](http://help.aliyun.com/document_detail/434131.htm)
29+
30+
<!-- docs-link -->
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resource "random_integer" "default" {
2+
min = 10000
3+
max = 99999
4+
}
5+
6+
# 添加一个加速域名
7+
resource "alicloud_cdn_domain_new" "domain" {
8+
domain_name = "mycdndomain-${random_integer.default.result}.alicloud-provider.cn"
9+
cdn_type = "download"
10+
scope = "overseas"
11+
sources {
12+
content = "myoss-${random_integer.default.result}.oss-rg-china-mainland.aliyuncs.com"
13+
type = "oss"
14+
priority = "20"
15+
port = 80
16+
weight = "15"
17+
}
18+
}
19+
20+
# 为加速域名配置一个访问IP白名单
21+
resource "alicloud_cdn_domain_config" "config-ip" {
22+
domain_name = alicloud_cdn_domain_new.domain.domain_name
23+
function_name = "ip_allow_list_set"
24+
function_args {
25+
arg_name = "ip_list"
26+
arg_value = "192.168.0.1"
27+
}
28+
}
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)