Skip to content

Commit 460fb7b

Browse files
committed
合并所有更改:重命名文件夹、terraform fmt、添加 region 变量、修正地域名、优化文档等
1 parent 2736e8c commit 460fb7b

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<!-- BEGIN_TF_DOCS -->
21
## Introduction
32

43
<!-- DOCS_DESCRIPTION_CN -->
5-
本示例用于实现解决方案[PAI 部署多形态的 Stable Diffusion WebUI 服务部署须知](https://www.aliyun.com/solution/tech-solution-deploy/2509703), 涉及到 PAI、NAS、NAT网关 等资源的创建/添加/挂载/关联/部署。
4+
本示例用于实现解决方案[PAI 部署多形态的 Stable Diffusion WebUI 服务部署须知](https://www.aliyun.com/solution/tech-solution-deploy/2509703), 涉及到 PAI、NAS、NAT网关 等资源的创建
65
<!-- DOCS_DESCRIPTION_CN -->
76

87
<!-- DOCS_DESCRIPTION_EN -->
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
provider "alicloud" {
2+
region = var.region
23
}
34

45
# 生成随机字符串
@@ -18,10 +19,10 @@ resource "alicloud_vpc" "vpc" {
1819

1920
# VSwitch
2021
resource "alicloud_vswitch" "vswitch" {
21-
vpc_id = alicloud_vpc.vpc.id
22+
vpc_id = alicloud_vpc.vpc.id
2223
availability_zone = var.zone_id
23-
cidr_block = "192.168.0.0/18"
24-
vswitch_name = "vswitch_SDWebUI"
24+
cidr_block = "192.168.0.0/18"
25+
vswitch_name = "vswitch_SDWebUI"
2526
}
2627

2728
# NAT网关
@@ -33,17 +34,17 @@ resource "alicloud_nat_gateway" "nat_gateway" {
3334
internet_charge_type = "PayByLcu"
3435
nat_type = "Enhanced"
3536
network_type = "internet"
36-
37+
3738
tags = {
3839
WebUI = "SD_WebUI"
3940
}
4041
}
4142

4243
# EIP
4344
resource "alicloud_eip" "eip" {
44-
name = "eip_SDWebUI"
45-
bandwidth = 200
46-
internet_charge_type = "PayByTraffic"
45+
name = "eip_SDWebUI"
46+
bandwidth = 200
47+
internet_charge_type = "PayByTraffic"
4748
}
4849

4950
# EIP关联到NAT网关
@@ -55,9 +56,9 @@ resource "alicloud_eip_association" "eip_association" {
5556
# SNAT条目
5657
resource "alicloud_snat_entry" "snat_entry" {
5758
snat_table_id = alicloud_nat_gateway.nat_gateway.snat_table_ids
58-
snat_ip = alicloud_eip.eip.ip_address
59-
source_cidr = "192.168.0.0/18"
60-
59+
snat_ip = alicloud_eip.eip.ip_address
60+
source_cidr = "192.168.0.0/18"
61+
6162
depends_on = [alicloud_eip_association.eip_association]
6263
}
6364

@@ -95,9 +96,9 @@ resource "alicloud_security_group_rule" "allow_https" {
9596
# NAS文件系统
9697
resource "alicloud_nas_file_system" "nas" {
9798
file_system_type = "standard"
98-
storage_type = "Performance"
99-
protocol_type = "NFS"
100-
encrypt_type = 0
99+
storage_type = "Performance"
100+
protocol_type = "NFS"
101+
encrypt_type = 0
101102
}
102103

103104
# NAS访问组
@@ -119,41 +120,41 @@ resource "alicloud_nas_access_rule" "nas_access_rule" {
119120

120121
# NAS挂载点
121122
resource "alicloud_nas_mount_target" "nas_mount_target" {
122-
vpc_id = alicloud_vpc.vpc.id
123-
vswitch_id = alicloud_vswitch.vswitch.id
123+
vpc_id = alicloud_vpc.vpc.id
124+
vswitch_id = alicloud_vswitch.vswitch.id
124125
security_group_id = alicloud_security_group.security_group.id
125-
status = "Active"
126-
file_system_id = alicloud_nas_file_system.nas.id
127-
network_type = "Vpc"
126+
status = "Active"
127+
file_system_id = alicloud_nas_file_system.nas.id
128+
network_type = "Vpc"
128129
access_group_name = alicloud_nas_access_group.nas_access_group.access_group_name
129-
130+
130131
depends_on = [alicloud_nas_access_rule.nas_access_rule]
131132
}
132133

133134
# PAI-EAS服务
134135
resource "alicloud_pai_service" "pai_eas" {
135136
service_config = jsonencode({
136137
metadata = {
137-
name = "sdwebui_${random_string.random_string.result}"
138-
instance = 1
139-
type = "SDCluster"
138+
name = "sdwebui_${random_string.random_string.result}"
139+
instance = 1
140+
type = "SDCluster"
140141
enable_webservice = "true"
141142
}
142143
cloud = {
143144
computing = {
144145
instance_type = var.instance_type
145-
instances = null
146+
instances = null
146147
}
147148
networking = {
148-
vpc_id = alicloud_vpc.vpc.id
149-
vswitch_id = alicloud_vswitch.vswitch.id
149+
vpc_id = alicloud_vpc.vpc.id
150+
vswitch_id = alicloud_vswitch.vswitch.id
150151
security_group_id = alicloud_security_group.security_group.id
151152
}
152153
}
153154
storage = [
154155
{
155156
nfs = {
156-
path = "/"
157+
path = "/"
157158
server = alicloud_nas_mount_target.nas_mount_target.mount_target_domain
158159
}
159160
properties = {
@@ -164,9 +165,9 @@ resource "alicloud_pai_service" "pai_eas" {
164165
]
165166
containers = [
166167
{
167-
image = "eas-registry-vpc.ap-southeast-1.cr.aliyuncs.com/pai-eas/stable-diffusion-webui:4.1"
168+
image = "eas-registry-vpc.ap-southeast-1.cr.aliyuncs.com/pai-eas/stable-diffusion-webui:4.1"
168169
script = "./webui.sh --listen --port 8000 --skip-version-check --no-hashing --no-download-sd-model --skip-install --api --filebrowser --cluster-status --sd-dynamic-cache --data-dir /code/stable-diffusion-webui/data-nas"
169-
port = 8000
170+
port = 8000
170171
}
171172
]
172173
meta = {
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
variable "region" {
2+
type = string
3+
description = "地域,由于在新加坡地域开通弹性公网 IP 服务后,访问 Civitai 和Github 的网速高效稳定,此处选择新加坡"
4+
default = "ap-southeast-1"
5+
}
6+
17
variable "zone_id" {
28
type = string
39
description = "可用区ID"
@@ -8,9 +14,9 @@ variable "instance_type" {
814
type = string
915
description = "PAI-EAS实例规格"
1016
default = "ecs.gn6i-c16g1.4xlarge"
11-
17+
1218
validation {
13-
condition = can(regex("(^ecs.*gn.*)|(^ml.*)|(^ecs.*gu.*)", var.instance_type))
19+
condition = can(regex("(^ecs.*gn.*)|(^ml.*)|(^ecs.*gu.*)", var.instance_type))
1420
error_message = "实例类型必须匹配模式 (^ecs.*gn.*)|(^ml.*)|(^ecs.*gu.*)"
1521
}
1622
}

0 commit comments

Comments
 (0)