-
Notifications
You must be signed in to change notification settings - Fork 25
/
entity_fetch.go
540 lines (476 loc) · 19.6 KB
/
entity_fetch.go
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
package aws
import (
"context"
"fmt"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/kentik/ktranslate/pkg/eggs/logger"
"github.com/kentik/patricia"
tree "github.com/kentik/patricia/string_tree"
)
// AWSEntities holds all of the entities fetched for a company
type AWSEntities struct {
Vpcs map[string]ec2.Vpc `json:"Vpcs"`
AvailabilityZones map[string]ec2.AvailabilityZone `json:"AvailabilityZones"`
Subnets map[string]ec2.Subnet `json:"Subnets"`
InternetGateways map[string]ec2.InternetGateway `json:"InternetGateways"`
NatGateways map[string]ec2.NatGateway `json:"NatGateways"`
TransitGateways map[string]ec2.TransitGateway `json:"TransitGateways"`
TransitGatewayAttachments map[string]ec2.TransitGatewayAttachment `json:"TransitGatewayAttachments"`
VpnGateways map[string]ec2.VpnGateway `json:"VpnGateways"`
VpcPeeringConnections map[string]ec2.VpcPeeringConnection `json:"VpcPeeringConnections"`
// TODO: Firewalls
// TODO: LoadBalancers map[string]ec2.ClassicLoadBalancer `json:"load_balancers"`
}
type AWSTopology struct {
Hierarchy AWSHierarchy `json:"Hierarchy"`
Entities AWSEntities `json:"Entities"`
}
func NewAWSTopology() AWSTopology {
return AWSTopology{
Hierarchy: NewAWSHierarchy(),
Entities: NewAWSEntities(),
}
}
type AWSHierarchy struct {
Regions map[string]RegionSkel `json:"Regions"`
SubnetTrieV4 *tree.TreeV4
SubnetTrieV6 *tree.TreeV6
}
func NewAWSHierarchy() AWSHierarchy {
return AWSHierarchy{
Regions: make(map[string]RegionSkel),
SubnetTrieV4: tree.NewTreeV4(),
SubnetTrieV6: tree.NewTreeV6(),
}
}
type VpcPeeringConnectionSkel struct {
RequesterVpcId string `json:"RequesterVpcId"`
AccepterVpcId string `json:"AccepterVpcId"`
}
type SubnetSkel struct {
SubnetId string `json:"SubnetId"`
NatGateways map[string]NatGatewaySkel `json:"NatGateways"`
}
func NewSubnetSkel(subnetId string) SubnetSkel {
return SubnetSkel{
SubnetId: subnetId,
NatGateways: make(map[string]NatGatewaySkel),
}
}
type InternetGatewaySkel struct {
InternetGatewayId string `json:"InternetGatewayId"`
InternetGatewayAttachments map[string]InternetGatewayAttachmentSkel `json:"InternetGatewayAttachments"`
}
func NewInternetGatewaySkel(id string) InternetGatewaySkel {
return InternetGatewaySkel{
InternetGatewayId: id,
InternetGatewayAttachments: make(map[string]InternetGatewayAttachmentSkel),
}
}
type InternetGatewayAttachmentSkel struct {
InternetGatewayId string `json:"InternetGatewayId"`
VpcId string `json:"VpcId"`
State string `json:"State"`
}
type NatGatewaySkel struct {
NatGatewayId string `json:"NatGatewayId"`
}
type TransitGatewaySkel struct {
TransitGatewayId string `json:"TransitGatewayId "`
TransitGatewayAttachments map[string]TransitGatewayAttachmentSkel `json:"TransitGatewayAttachment"`
}
func NewTransitGatewaySkel(id string) TransitGatewaySkel {
return TransitGatewaySkel{
TransitGatewayId: id,
TransitGatewayAttachments: make(map[string]TransitGatewayAttachmentSkel),
}
}
type TransitGatewayAttachmentSkel struct {
TransitGatewayAttachmentId string `json:"TransitGatewayAttachmentId"`
}
type VpnGatewaySkel struct {
VpnGatewayId string `json:"VpnGatewayId"`
}
type VpcSkel struct {
VpcId string `json:"VpcId"`
Subnets map[string]SubnetSkel `json:"Subnets"`
TransitGatewayAttachments map[string]TransitGatewayAttachmentSkel `json:"TransitGatewayAttachments"` // by GatewayAttachmentId
InternetGatewayAttachments map[string]InternetGatewayAttachmentSkel `json:"InternetGatewayAttachments"` // by InternetGatewayId
VpcPeeringConnections map[string]VpcPeeringConnectionSkel `json:"VpcPeeringConnections"` // by VpcPeeringConnectionId
}
func NewVpcSkel(id string) VpcSkel {
return VpcSkel{
VpcId: id,
Subnets: make(map[string]SubnetSkel),
TransitGatewayAttachments: make(map[string]TransitGatewayAttachmentSkel),
InternetGatewayAttachments: make(map[string]InternetGatewayAttachmentSkel),
}
}
type AvailabilityZoneSkel struct {
ZoneId string `json:"ZoneId"`
}
type RegionSkel struct {
Name string `json:"Name"`
Vpcs map[string]VpcSkel `json:"Vpcs"`
AvailabilityZones map[string]AvailabilityZoneSkel `json:"AvailabilityZones"`
InternetGateways map[string]InternetGatewaySkel `json:"InternetGateways"`
TransitGateways map[string]TransitGatewaySkel `json:"TransitGateways"`
VpnGateways map[string]VpnGatewaySkel `json:"VpnGateways"`
}
func NewRegionSkel(name string) RegionSkel {
return RegionSkel{
Name: strings.ToLower(name),
Vpcs: make(map[string]VpcSkel),
AvailabilityZones: make(map[string]AvailabilityZoneSkel),
InternetGateways: make(map[string]InternetGatewaySkel),
TransitGateways: make(map[string]TransitGatewaySkel),
VpnGateways: make(map[string]VpnGatewaySkel),
}
}
func NewAWSEntities() AWSEntities {
return AWSEntities{
Vpcs: make(map[string]ec2.Vpc),
AvailabilityZones: make(map[string]ec2.AvailabilityZone),
Subnets: make(map[string]ec2.Subnet),
InternetGateways: make(map[string]ec2.InternetGateway),
NatGateways: make(map[string]ec2.NatGateway),
TransitGateways: make(map[string]ec2.TransitGateway),
TransitGatewayAttachments: make(map[string]ec2.TransitGatewayAttachment),
VpnGateways: make(map[string]ec2.VpnGateway),
VpcPeeringConnections: make(map[string]ec2.VpcPeeringConnection),
}
}
// FetchAllEntities fetches all the things, and returns whether it was a total success
func FetchAllEntities(ctx context.Context, log logger.ContextL, arnName string, regions []string) (AWSTopology, bool) {
topology := NewAWSTopology()
sleepTime := 50 * time.Millisecond
totalSuccess := true
start := time.Now()
vpcToRegion := make(map[string]string)
for _, regionName := range regions {
session := session.Must(session.NewSession(&aws.Config{
Region: aws.String(regionName),
}))
if _, found := topology.Hierarchy.Regions[regionName]; !found {
topology.Hierarchy.Regions[regionName] = NewRegionSkel(regionName)
}
ec2cli := ec2.New(session,
&aws.Config{
Credentials: stscreds.NewCredentials(session, arnName),
})
// Vpcs
if err := fetchVpcs(ctx, ec2cli, &topology, regionName, vpcToRegion, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// Availability Zones
if err := fetchAvailabilityZones(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// InternetGateways
if err := fetchInternetGateways(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// TransitGateways
if err := fetchTransitGateways(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// VpnGateways
if err := fetchVPNGateways(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// Subnets
if err := fetchSubnets(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// NatGateways
if err := fetchNATGateways(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// TransitGatewayAttachments
if err := fetchTransitGatewayAttachments(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// VpcPeeringConnections
if err := fetchVpcPeeringConnections(ctx, ec2cli, &topology, regionName, sleepTime); err != nil {
totalSuccess = false
log.Errorf("region: %s, arn: %s - %s", regionName, arnName, err)
}
// TODO: Firewalls
// TODO: LoadBalancers
}
// VpcPeeringConnections cross VPCs - we've loaded them all up in the entities collections,
// but need to tie them to VPCs after crawling all regions, since they can span regions
for pcId, pc := range topology.Entities.VpcPeeringConnections {
requesterId := ""
accepterId := ""
if pc.RequesterVpcInfo != nil {
requesterId = safeStr(pc.RequesterVpcInfo.VpcId)
}
if pc.AccepterVpcInfo != nil {
accepterId = safeStr(pc.AccepterVpcInfo.VpcId)
}
if requesterId == "" && accepterId == "" {
continue
}
skel := VpcPeeringConnectionSkel{
RequesterVpcId: requesterId,
AccepterVpcId: accepterId,
}
attachSkelToVpc := func(vpcId string) {
if vpcId == "" {
return
}
if regionName, found := vpcToRegion[vpcId]; found {
if _, found := topology.Hierarchy.Regions[regionName].Vpcs[vpcId]; !found {
// I don't think this should happen
topology.Hierarchy.Regions[regionName].Vpcs[vpcId] = NewVpcSkel(vpcId)
}
topology.Hierarchy.Regions[regionName].Vpcs[vpcId].VpcPeeringConnections[pcId] = skel
}
}
attachSkelToVpc(requesterId)
attachSkelToVpc(accepterId)
}
log.Infof("Finished fetching entites in %s", time.Since(start))
return topology, totalSuccess
}
func fetchVpcs(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, vpcToRegion map[string]string, sleepTime time.Duration) error {
err := ec2cli.DescribeVpcsPagesWithContext(ctx, &ec2.DescribeVpcsInput{}, func(page *ec2.DescribeVpcsOutput, lastPage bool) bool {
for _, vpc := range page.Vpcs {
if vpc == nil || vpc.VpcId == nil {
continue
}
vpcToRegion[*vpc.VpcId] = regionName
topology.Entities.Vpcs[*vpc.VpcId] = *vpc
topology.Hierarchy.Regions[regionName].Vpcs[*vpc.VpcId] = NewVpcSkel(*vpc.VpcId)
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching VPCS: %s.", err)
}
return nil
}
func fetchAvailabilityZones(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
out, err := ec2cli.DescribeAvailabilityZonesWithContext(ctx, &ec2.DescribeAvailabilityZonesInput{})
if err != nil {
return fmt.Errorf("There was an error when fetching availability zones: %s.", err)
}
for _, az := range out.AvailabilityZones {
if az == nil || az.ZoneId == nil {
continue
}
topology.Entities.AvailabilityZones[*az.ZoneId] = *az
topology.Hierarchy.Regions[regionName].AvailabilityZones[*az.ZoneId] = AvailabilityZoneSkel{ZoneId: *az.ZoneId}
}
time.Sleep(sleepTime)
return nil
}
func fetchSubnets(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
err := ec2cli.DescribeSubnetsPagesWithContext(ctx,
&ec2.DescribeSubnetsInput{},
func(page *ec2.DescribeSubnetsOutput, lastPage bool) bool {
for _, subnet := range page.Subnets {
if subnet == nil || subnet.SubnetId == nil {
continue
}
topology.Entities.Subnets[*subnet.SubnetId] = *subnet
if subnet.VpcId == nil {
continue
}
if _, found := topology.Hierarchy.Regions[regionName].Vpcs[*subnet.VpcId]; !found {
// shouldn't happen - we crawled VPCs first - do this just in case
topology.Hierarchy.Regions[regionName].Vpcs[*subnet.VpcId] = NewVpcSkel(*subnet.VpcId)
}
topology.Hierarchy.Regions[regionName].Vpcs[*subnet.VpcId].Subnets[*subnet.SubnetId] = NewSubnetSkel(*subnet.SubnetId)
// Now, add to out lookup.
ip4, ip6, err := patricia.ParseIPFromString(*subnet.CidrBlock)
if err != nil {
continue
}
if ip4 != nil {
topology.Hierarchy.SubnetTrieV4.Set(*ip4, *subnet.SubnetId)
} else {
topology.Hierarchy.SubnetTrieV6.Set(*ip6, *subnet.SubnetId)
}
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching subnets: %s.", err)
}
return nil
}
func fetchInternetGateways(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
err := ec2cli.DescribeInternetGatewaysPagesWithContext(ctx,
&ec2.DescribeInternetGatewaysInput{},
func(page *ec2.DescribeInternetGatewaysOutput, lastPage bool) bool {
for _, gw := range page.InternetGateways {
if gw == nil || gw.InternetGatewayId == nil {
continue
}
topology.Entities.InternetGateways[*gw.InternetGatewayId] = *gw
topology.Hierarchy.Regions[regionName].InternetGateways[*gw.InternetGatewayId] = NewInternetGatewaySkel(*gw.InternetGatewayId)
// add the attachments to both the internet gateway, and the VPC
for _, gwa := range gw.Attachments {
if gwa.VpcId == nil {
continue
}
skel := InternetGatewayAttachmentSkel{
InternetGatewayId: *gw.InternetGatewayId,
VpcId: *gwa.VpcId,
State: safeStr(gwa.State),
}
topology.Hierarchy.Regions[regionName].InternetGateways[*gw.InternetGatewayId].InternetGatewayAttachments[*gwa.VpcId] = skel
if _, found := topology.Hierarchy.Regions[regionName].Vpcs[*gwa.VpcId]; !found {
// shouldn't happen - we crawled VPCs first - do this just in case
topology.Hierarchy.Regions[regionName].Vpcs[*gwa.VpcId] = NewVpcSkel(*gwa.VpcId)
}
topology.Hierarchy.Regions[regionName].Vpcs[*gwa.VpcId].InternetGatewayAttachments[*gw.InternetGatewayId] = skel
}
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching internet gateways: %s.", err)
}
return nil
}
func fetchNATGateways(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
err := ec2cli.DescribeNatGatewaysPagesWithContext(ctx,
&ec2.DescribeNatGatewaysInput{},
func(page *ec2.DescribeNatGatewaysOutput, lastPage bool) bool {
for _, gw := range page.NatGateways {
if gw == nil || gw.NatGatewayId == nil {
continue
}
topology.Entities.NatGateways[*gw.NatGatewayId] = *gw
if gw.SubnetId == nil || gw.VpcId == nil {
continue
}
if _, found := topology.Hierarchy.Regions[regionName].Vpcs[*gw.VpcId]; !found {
// shouldn't happen, but just in case
topology.Hierarchy.Regions[regionName].Vpcs[*gw.VpcId] = NewVpcSkel(*gw.VpcId)
}
if _, found := topology.Hierarchy.Regions[regionName].Vpcs[*gw.VpcId].Subnets[*gw.SubnetId]; !found {
// shouldn't happen, but just in case
topology.Hierarchy.Regions[regionName].Vpcs[*gw.VpcId].Subnets[*gw.SubnetId] = NewSubnetSkel(*gw.SubnetId)
}
topology.Hierarchy.Regions[regionName].Vpcs[*gw.VpcId].Subnets[*gw.SubnetId].NatGateways[*gw.NatGatewayId] = NatGatewaySkel{NatGatewayId: *gw.NatGatewayId}
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching NAT gateways: %s.", err)
}
return nil
}
func fetchTransitGateways(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
err := ec2cli.DescribeTransitGatewaysPagesWithContext(ctx,
&ec2.DescribeTransitGatewaysInput{},
func(page *ec2.DescribeTransitGatewaysOutput, lastPage bool) bool {
for _, gw := range page.TransitGateways {
if gw == nil || gw.TransitGatewayId == nil {
continue
}
topology.Entities.TransitGateways[*gw.TransitGatewayId] = *gw
topology.Hierarchy.Regions[regionName].TransitGateways[*gw.TransitGatewayId] = NewTransitGatewaySkel(*gw.TransitGatewayId)
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching transit gateways: %s.", err)
}
return nil
}
func fetchTransitGatewayAttachments(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
err := ec2cli.DescribeTransitGatewayAttachmentsPagesWithContext(ctx,
&ec2.DescribeTransitGatewayAttachmentsInput{},
func(page *ec2.DescribeTransitGatewayAttachmentsOutput, lastPage bool) bool {
for _, at := range page.TransitGatewayAttachments {
if at == nil || at.TransitGatewayAttachmentId == nil {
continue
}
topology.Entities.TransitGatewayAttachments[*at.TransitGatewayAttachmentId] = *at
// add the attachment to the transit gateway
if at.TransitGatewayId != nil {
if _, found := topology.Hierarchy.Regions[regionName].TransitGateways[*at.TransitGatewayId]; !found {
// shouldn't happen
topology.Hierarchy.Regions[regionName].TransitGateways[*at.TransitGatewayId] = NewTransitGatewaySkel(*at.TransitGatewayId)
}
topology.Hierarchy.Regions[regionName].TransitGateways[*at.TransitGatewayId].TransitGatewayAttachments[*at.TransitGatewayAttachmentId] = TransitGatewayAttachmentSkel{TransitGatewayAttachmentId: *at.TransitGatewayId}
}
// also add the attachment to the appropriate resource, if we model it
// valid values for ResourceType: vpc, vpn, direct-connect-gateway, peering, connect
if at.ResourceId != nil && at.ResourceType != nil && strings.ToLower(*at.ResourceType) == "vpc" {
// VPCs for this region should already have been loaded
if _, found := topology.Hierarchy.Regions[regionName].Vpcs[*at.ResourceId]; !found {
// shouldn't happen - we crawled VPCs first - do this just in case
topology.Hierarchy.Regions[regionName].Vpcs[*at.ResourceId] = NewVpcSkel(*at.ResourceId)
}
topology.Hierarchy.Regions[regionName].Vpcs[*at.ResourceId].TransitGatewayAttachments[*at.TransitGatewayAttachmentId] = TransitGatewayAttachmentSkel{TransitGatewayAttachmentId: *at.TransitGatewayId}
}
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching transit gateways attachments: %s.", err)
}
return nil
}
func fetchVPNGateways(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
output, err := ec2cli.DescribeVpnGatewaysWithContext(ctx, &ec2.DescribeVpnGatewaysInput{})
if err != nil {
return fmt.Errorf("There was an error when fetching VPN gateways: %s.", err)
}
for _, gw := range output.VpnGateways {
if gw == nil || gw.VpnGatewayId == nil {
continue
}
topology.Entities.VpnGateways[*gw.VpnGatewayId] = *gw
topology.Hierarchy.Regions[regionName].VpnGateways[*gw.VpnGatewayId] = VpnGatewaySkel{VpnGatewayId: *gw.VpnGatewayId}
}
time.Sleep(sleepTime)
return nil
}
func safeStr(strPtr *string) string {
if strPtr == nil {
return ""
}
return *strPtr
}
func fetchVpcPeeringConnections(ctx context.Context, ec2cli *ec2.EC2, topology *AWSTopology, regionName string, sleepTime time.Duration) error {
err := ec2cli.DescribeVpcPeeringConnectionsPages(&ec2.DescribeVpcPeeringConnectionsInput{}, func(page *ec2.DescribeVpcPeeringConnectionsOutput, lastPage bool) bool {
for _, pc := range page.VpcPeeringConnections {
if pc.VpcPeeringConnectionId == nil {
continue
}
topology.Entities.VpcPeeringConnections[*pc.VpcPeeringConnectionId] = *pc
}
time.Sleep(sleepTime)
return true
})
if err != nil {
return fmt.Errorf("There was an error when fetching VPC peering connections gateways: %s.", err)
}
return nil
}