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

Commit 8a86023

Browse files
authored
Merge pull request #15 from qqshfox/fix_iam_for_china_region
add a new var IsChinaRegion to fix for China Region
2 parents 8ec49a6 + c346741 commit 8a86023

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

@@ -172,6 +173,7 @@ type Cluster struct {
172173
MapPublicIPs bool `yaml:"mapPublicIPs,omitempty"`
173174
Experimental Experimental `yaml:"experimental"`
174175
providedEncryptService encryptService
176+
IsChinaRegion bool
175177
}
176178

177179
type Subnet struct {
@@ -318,6 +320,8 @@ func (c Cluster) Config() (*Config, error) {
318320
config.EtcdEndpoints = etcdEndpoints.String()
319321
config.EtcdInitialCluster = etcdInitialCluster.String()
320322

323+
config.IsChinaRegion = strings.HasPrefix(config.Region, "cn")
324+
321325
return &config, nil
322326
}
323327

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)