11provider "alicloud" {
2+ region = var. region
23}
34
45# 生成随机字符串
@@ -18,10 +19,10 @@ resource "alicloud_vpc" "vpc" {
1819
1920# VSwitch
2021resource "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
4344resource "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条目
5657resource "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文件系统
9697resource "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挂载点
121122resource "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服务
134135resource "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 = {
0 commit comments