-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtofu_init.sh
160 lines (137 loc) · 2.96 KB
/
tofu_init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/sh
# 创建opentofu模版文件夹
mkdir tofu-emplate
# 进入
cd tofu-emplate
# 阿里云:
# -----------------------------------
# 创建阿里云opentofu模版文件夹
mkdir -p aliyun
# 进入
cd aliyun
# aliyun.tf文件并写入内容
cat << EOF > aliyun.tf
terraform {
required_providers {
alicloud = {
source = "aliyun/alicloud"
version = "1.189.0"
}
}
}
provider "alicloud" {
# Configuration options
}
EOF
# 退出
cd ..
echo "Folder created and aliyun.tf file written successfully."
# 腾讯云:
# -----------------------------------
# 创建腾讯云opentofu模版文件夹
mkdir -p tencent
# 进入
cd tencent
# tencentcloudstack.tf文件并写入内容
cat << EOF > tencentcloudstack.tf
terraform {
required_providers {
tencentcloud = {
source = "tencentcloudstack/tencentcloud"
version = "1.81.16"
}
}
}
provider "tencentcloud" {
# Configuration options
}
EOF
# 退出
cd ..
echo "Folder created and tencentcloudstack.tf file written successfully."
# 百度云:
# -----------------------------------
# 创建百度云opentofu模版文件夹
mkdir -p baidu
# 进入
cd baidu
# baidubce.tf文件并写入内容
cat << EOF > baidubce.tf
terraform {
required_providers {
baiducloud = {
source = "baidubce/baiducloud"
version = "1.19.35"
}
}
}
provider "baiducloud" {
# Configuration options
}
EOF
# 退出
cd ..
echo "Folder created and baidubce.tf file written successfully."
# 华为云:
# -----------------------------------
# 创建华为云opentofu模版文件夹
mkdir -p huawei
# 进入
cd huawei
# huaweicloud.tf文件并写入内容
cat << EOF > huaweicloud.tf
terraform {
required_providers {
huaweicloud = {
source = "huaweicloud/huaweicloud"
version = "1.44.2"
}
}
}
provider "huaweicloud" {
# Configuration options
}
EOF
# 退出
cd ..
echo "Folder created and huaweicloud.tf file written successfully."
# AWS云:
# -----------------------------------
# 创建AWS云opentofu模版文件夹
mkdir -p aws
# 进入
cd aws
# huaweicloud.tf文件并写入内容
cat << EOF > hashicorp.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.65.0"
}
}
}
provider "aws" {
# Configuration options
}
EOF
# 退出
cd ..
echo "Folder created and hashicorp.tf file written successfully."
# 执行tofu init 生成依赖项文件:
# -----------------------------------
# 初始化aliyun opentofu配置文件
cd /app/tofu-emplate/aliyun/
TF_PLUGIN_CACHE_DIR=/app/tofu-plugin tofu init
# 初始化tencent opentofu配置文件
cd /app/tofu-emplate/tencent/
TF_PLUGIN_CACHE_DIR=/app/tofu-plugin tofu init
# 初始化baidu opentofu配置文件
cd /app/tofu-emplate/baidu/
TF_PLUGIN_CACHE_DIR=/app/tofu-plugin tofu init
# 初始化huawei opentofu配置文件
cd /app/tofu-emplate/huawei/
TF_PLUGIN_CACHE_DIR=/app/tofu-plugin tofu init
# 初始化aws opentofu配置文件
cd /app/tofu-emplate/aws/
TF_PLUGIN_CACHE_DIR=/app/tofu-plugin tofu init