@@ -118,7 +118,6 @@ func NewCloud(cfg CloudConfig, metricsRegisterer prometheus.Registerer) (Cloud,
118
118
return nil , errors .Wrap (err , "failed to get VPC ID" )
119
119
}
120
120
cfg .VpcID = vpcID
121
-
122
121
return & defaultCloud {
123
122
cfg : cfg ,
124
123
ec2 : ec2Service ,
@@ -137,7 +136,7 @@ func getVpcID(cfg CloudConfig, ec2Service services.EC2, metadata services.EC2Met
137
136
}
138
137
139
138
if cfg .VpcTags != nil {
140
- return inferVPCIDFromTags (ec2Service , cfg .VpcTags [cfg .VpcNameTagKey ])
139
+ return inferVPCIDFromTags (ec2Service , cfg .VpcNameTagKey , cfg . VpcTags [cfg .VpcNameTagKey ])
141
140
}
142
141
143
142
return inferVPCID (metadata , ec2Service )
@@ -179,14 +178,12 @@ func inferVPCID(metadata services.EC2Metadata, ec2Service services.EC2) (string,
179
178
return "" , amerrors .NewAggregate (errList )
180
179
}
181
180
182
- func inferVPCIDFromTags (ec2Service services.EC2 , vpcNameTagKey string ) (string , error ) {
181
+ func inferVPCIDFromTags (ec2Service services.EC2 , VpcNameTagKey string , VpcNameTagValue string ) (string , error ) {
183
182
vpcs , err := ec2Service .DescribeVPCsAsList (context .Background (), & ec2.DescribeVpcsInput {
184
183
Filters : []* ec2.Filter {
185
184
{
186
- Name : & vpcNameTagKey ,
187
- //Values: []*string{
188
- // aws.String("owned"),
189
- //},
185
+ Name : aws .String ("tag:" + VpcNameTagKey ),
186
+ Values : []* string {aws .String (VpcNameTagValue )},
190
187
},
191
188
},
192
189
})
0 commit comments