Skip to content

Commit 21b4fbd

Browse files
author
Jeff Carter
committed
fix errors when running with new services
1 parent 20ea0e1 commit 21b4fbd

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

lister/cloudformation_stack.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ func (l AWSCloudFormationStack) List(cfg option.AWSetsConfig) (*resource.Group,
5555
if rt == resource.Unnecessary {
5656
continue
5757
}
58+
if rsum.PhysicalResourceId == nil {
59+
// If stack is in certain statuses (like DELETE_FAILED) the physical id may be nil as this
60+
// particular resource may have been deleted
61+
continue
62+
}
5863
resourceId := *rsum.PhysicalResourceId
5964
if strings.Contains(resourceId, "arn:") {
6065
resourceArn := arn.Parse(resourceId)

lister/ec2_vpcendpointservice.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func (l AWSEc2VpcEndpointService) List(cfg option.AWSetsConfig) (*resource.Group
3838
return nil, err
3939
}
4040
for _, v := range res.ServiceDetails {
41+
if v.ServiceId == nil {
42+
// some Amazon owned vpc service endpoints have null IDs
43+
continue
44+
}
4145
r := resource.New(cfg, resource.Ec2VpcEndpointService, v.ServiceId, v.ServiceName, v)
4246

4347
configs := make([]*types.ServiceConfiguration, 0)

lister/glue_crawler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (l AWSGlueCrawler) List(cfg option.AWSetsConfig) (*resource.Group, error) {
3535
}
3636
for _, v := range res.Crawlers {
3737
r := resource.NewVersion(cfg, resource.GlueCrawler, v.Name, v.Name, v.Version, v)
38-
r.AddARNRelation(resource.IamRole, v.Role)
38+
r.AddRelation(resource.IamRole, v.Role, "")
3939
r.AddRelation(resource.GlueDatabase, v.DatabaseName, "")
4040
// TODO: review relationships to s3, ddb, jdbc
4141

resource/resource.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package resource
33
import (
44
"encoding/json"
55
"fmt"
6+
"os"
67
"sort"
78
"strings"
89
"sync"
@@ -74,8 +75,8 @@ func makeResource(account, region string, kind ResourceType, iId, iName, iVersio
7475
Attributes: asMap,
7576
Tags: make(map[string]string),
7677
}
77-
if strings.Contains(id, "arn:") {
78-
fmt.Printf("new resource contains arn: %s - %s\n", kind.String(), id)
78+
if strings.Contains(id, "arn:") && kind != SsmPatchBaseline {
79+
fmt.Fprintf(os.Stderr, "new resource contains arn: %s - %s\n", kind.String(), id)
7980
}
8081
if tags, ok := asMap["Tags"]; ok {
8182
switch t := tags.(type) {
@@ -97,7 +98,7 @@ func makeResource(account, region string, kind ResourceType, iId, iName, iVersio
9798
case nil:
9899
// no op
99100
default:
100-
fmt.Printf("Unknown tag type: %T\n", t)
101+
fmt.Fprintf(os.Stderr, "Unknown tag type: %T\n", t)
101102
}
102103
}
103104
return resource
@@ -127,7 +128,7 @@ func (r *Resource) AddARNRelation(kind ResourceType, iArn interface{}) {
127128
}
128129
if !strings.Contains(sArn, "arn:") {
129130
// TODO: remove printing
130-
fmt.Printf("resource %+v tried adding relationsip that was not an ARN: %s-%s", r.Identifier, kind.String(), sArn)
131+
fmt.Fprintf(os.Stderr, "resource %+v tried adding relationsip that was not an ARN: %s - %s\n", r.Identifier, kind.String(), sArn)
131132
return
132133
}
133134
parsedArn := arn.Parse(sArn)
@@ -156,7 +157,7 @@ func (r *Resource) addRelation(account string, region string, kind ResourceType,
156157

157158
if strings.Contains(id, "arn:") {
158159
// TODO: remove printing
159-
fmt.Printf("new relation with %s has arn: %s - %s\n", r.Type.String(), kind.String(), id)
160+
fmt.Fprintf(os.Stderr, "new relation with %s has arn: %s - %s\n", r.Type.String(), kind.String(), id)
160161
}
161162
if strings.HasPrefix(kind.String(), "iam/") ||
162163
strings.HasPrefix(kind.String(), "route53/") ||

0 commit comments

Comments
 (0)