-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeff Carter
committed
Nov 23, 2020
1 parent
86791f1
commit 52f8a85
Showing
12 changed files
with
337 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package lister | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudfront" | ||
"github.com/trek10inc/awsets/context" | ||
"github.com/trek10inc/awsets/resource" | ||
) | ||
|
||
var listCloudfrontKeyGroupOnce sync.Once | ||
|
||
type AWSCloudfrontKeyGroup struct { | ||
} | ||
|
||
func init() { | ||
i := AWSCloudfrontKeyGroup{} | ||
listers = append(listers, i) | ||
} | ||
|
||
func (l AWSCloudfrontKeyGroup) Types() []resource.ResourceType { | ||
return []resource.ResourceType{resource.CloudFrontKeyGroup} | ||
} | ||
|
||
func (l AWSCloudfrontKeyGroup) List(ctx context.AWSetsCtx) (*resource.Group, error) { | ||
svc := cloudfront.NewFromConfig(ctx.AWSCfg) | ||
|
||
rg := resource.NewGroup() | ||
var outerErr error | ||
|
||
listCloudfrontKeyGroupOnce.Do(func() { | ||
err := Paginator(func(nt *string) (*string, error) { | ||
res, err := svc.ListKeyGroups(ctx.Context, &cloudfront.ListKeyGroupsInput{ | ||
MaxItems: aws.String("100"), | ||
Marker: nt, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if res.KeyGroupList == nil { | ||
return nil, nil | ||
} | ||
for _, item := range res.KeyGroupList.Items { | ||
kg := item.KeyGroup | ||
r := resource.NewGlobal(ctx, resource.CloudFrontKeyGroup, kg.Id, kg.Id, kg) | ||
|
||
rg.AddResource(r) | ||
} | ||
return res.KeyGroupList.NextMarker, nil | ||
}) | ||
if err != nil { | ||
outerErr = err | ||
} | ||
}) | ||
|
||
return rg, outerErr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package lister | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudfront" | ||
"github.com/trek10inc/awsets/context" | ||
"github.com/trek10inc/awsets/resource" | ||
) | ||
|
||
var listCloudfrontPublicKeyOnce sync.Once | ||
|
||
type AWSCloudfrontPublicKey struct { | ||
} | ||
|
||
func init() { | ||
i := AWSCloudfrontPublicKey{} | ||
listers = append(listers, i) | ||
} | ||
|
||
func (l AWSCloudfrontPublicKey) Types() []resource.ResourceType { | ||
return []resource.ResourceType{resource.CloudFrontPublicKey} | ||
} | ||
|
||
func (l AWSCloudfrontPublicKey) List(ctx context.AWSetsCtx) (*resource.Group, error) { | ||
svc := cloudfront.NewFromConfig(ctx.AWSCfg) | ||
|
||
rg := resource.NewGroup() | ||
var outerErr error | ||
|
||
listCloudfrontPublicKeyOnce.Do(func() { | ||
err := Paginator(func(nt *string) (*string, error) { | ||
res, err := svc.ListPublicKeys(ctx.Context, &cloudfront.ListPublicKeysInput{ | ||
MaxItems: aws.String("100"), | ||
Marker: nt, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if res.PublicKeyList == nil { | ||
return nil, nil | ||
} | ||
for _, item := range res.PublicKeyList.Items { | ||
r := resource.NewGlobal(ctx, resource.CloudFrontPublicKey, item.Id, item.Name, item) | ||
|
||
rg.AddResource(r) | ||
} | ||
return res.PublicKeyList.NextMarker, nil | ||
}) | ||
if err != nil { | ||
outerErr = err | ||
} | ||
}) | ||
|
||
return rg, outerErr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package lister | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/iot" | ||
"github.com/trek10inc/awsets/arn" | ||
"github.com/trek10inc/awsets/context" | ||
"github.com/trek10inc/awsets/resource" | ||
) | ||
|
||
type AWSIoTTopicRuleDestination struct { | ||
} | ||
|
||
func init() { | ||
i := AWSIoTTopicRuleDestination{} | ||
listers = append(listers, i) | ||
} | ||
|
||
func (l AWSIoTTopicRuleDestination) Types() []resource.ResourceType { | ||
return []resource.ResourceType{resource.IotTopicRuleDestination} | ||
} | ||
|
||
func (l AWSIoTTopicRuleDestination) List(ctx context.AWSetsCtx) (*resource.Group, error) { | ||
|
||
svc := iot.NewFromConfig(ctx.AWSCfg) | ||
|
||
rg := resource.NewGroup() | ||
err := Paginator(func(nt *string) (*string, error) { | ||
res, err := svc.ListTopicRuleDestinations(ctx.Context, &iot.ListTopicRuleDestinationsInput{ | ||
MaxResults: aws.Int32(100), | ||
NextToken: nt, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to list iot topic rule destinations: %w", err) | ||
} | ||
for _, destination := range res.DestinationSummaries { | ||
dArn := arn.ParseP(destination.Arn) | ||
r := resource.New(ctx, resource.IotTopicRuleDestination, dArn.ResourceId, dArn.ResourceId, destination) | ||
|
||
rg.AddResource(r) | ||
} | ||
return res.NextToken, nil | ||
}) | ||
return rg, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package lister | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/signer" | ||
"github.com/trek10inc/awsets/arn" | ||
"github.com/trek10inc/awsets/context" | ||
"github.com/trek10inc/awsets/resource" | ||
) | ||
|
||
type AWSSignerSigningProfile struct { | ||
} | ||
|
||
func init() { | ||
i := AWSSignerSigningProfile{} | ||
listers = append(listers, i) | ||
} | ||
|
||
func (l AWSSignerSigningProfile) Types() []resource.ResourceType { | ||
return []resource.ResourceType{resource.SignerSigningProfile} | ||
} | ||
|
||
func (l AWSSignerSigningProfile) List(ctx context.AWSetsCtx) (*resource.Group, error) { | ||
svc := signer.NewFromConfig(ctx.AWSCfg) | ||
rg := resource.NewGroup() | ||
err := Paginator(func(nt *string) (*string, error) { | ||
res, err := svc.ListSigningProfiles(ctx.Context, &signer.ListSigningProfilesInput{ | ||
MaxResults: aws.Int32(100), | ||
NextToken: nt, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, v := range res.Profiles { | ||
profileArn := arn.ParseP(v.Arn) | ||
r := resource.New(ctx, resource.SignerSigningProfile, profileArn.ResourceId, v.ProfileName, v) | ||
|
||
rg.AddResource(r) | ||
} | ||
return res.NextToken, nil | ||
}) | ||
return rg, err | ||
} |
Oops, something went wrong.