Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit c346741

Browse files
qqshfoxHanfei Shen
authored and
Hanfei Shen
committed
add a new var IsChinaRegion to fix for China Region
1 parent b2f425d commit c346741

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

config/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func newDefaultCluster() *Cluster {
6767
Subnets: []*Subnet{},
6868
MapPublicIPs: true,
6969
Experimental: experimental,
70+
IsChinaRegion: false,
7071
}
7172
}
7273

@@ -171,6 +172,7 @@ type Cluster struct {
171172
MapPublicIPs bool `yaml:"mapPublicIPs,omitempty"`
172173
Experimental Experimental `yaml:"experimental"`
173174
providedEncryptService encryptService
175+
IsChinaRegion bool
174176
}
175177

176178
type Subnet struct {
@@ -313,6 +315,8 @@ func (c Cluster) Config() (*Config, error) {
313315
config.EtcdEndpoints = etcdEndpoints.String()
314316
config.EtcdInitialCluster = etcdInitialCluster.String()
315317

318+
config.IsChinaRegion = strings.HasPrefix(config.Region, "cn")
319+
316320
return &config, nil
317321
}
318322

config/templates/stack-template.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
"Effect": "Allow",
175175
"Principal": {
176176
"Service": [
177-
"ec2.amazonaws.com"
177+
"ec2.amazonaws.com{{if .IsChinaRegion}}.cn{{end}}"
178178
]
179179
}
180180
}
@@ -221,7 +221,7 @@
221221
"Effect": "Allow",
222222
"Principal": {
223223
"Service": [
224-
"ec2.amazonaws.com"
224+
"ec2.amazonaws.com{{if .IsChinaRegion}}.cn{{end}}"
225225
]
226226
}
227227
}
@@ -286,7 +286,7 @@
286286
"Effect": "Allow",
287287
"Principal": {
288288
"Service": [
289-
"ec2.amazonaws.com"
289+
"ec2.amazonaws.com{{if .IsChinaRegion}}.cn{{end}}"
290290
]
291291
}
292292
}

0 commit comments

Comments
 (0)