Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 7771ef6

Browse files
authored
Adding tag support for FirehoseDeliveryStreams (#1088)
* adding code for removing custom origin request policies * rename resource * test for replication * revert secretsmanager change * undo this * revert mod and sum changes * add resources for redshift scheduled actions * remove cloudfront resource * clean up * cloudwatch rum app * remove rum * add cloudfront origin request policy * remove * test release pipeline * add these two * update agent to self-hosted * initial commit without storing the latest tag, max tags = 1 * initial commit without storing the latest tag, max tags = 1 * simplified the if-statement * PR ready * Update release.yaml
1 parent 5342982 commit 7771ef6

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

resources/firehose-deliverystreams.go

+35-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import (
44
"github.com/aws/aws-sdk-go/aws"
55
"github.com/aws/aws-sdk-go/aws/session"
66
"github.com/aws/aws-sdk-go/service/firehose"
7+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
78
)
89

910
type FirehoseDeliveryStream struct {
1011
svc *firehose.Firehose
1112
deliveryStreamName *string
13+
tags []*firehose.Tag
1214
}
1315

1416
func init() {
@@ -18,6 +20,7 @@ func init() {
1820
func ListFirehoseDeliveryStreams(sess *session.Session) ([]Resource, error) {
1921
svc := firehose.New(sess)
2022
resources := []Resource{}
23+
tags := []*firehose.Tag{}
2124
var lastDeliveryStreamName *string
2225

2326
params := &firehose.ListDeliveryStreamsInput{
@@ -31,14 +34,35 @@ func ListFirehoseDeliveryStreams(sess *session.Session) ([]Resource, error) {
3134
}
3235

3336
for _, deliveryStreamName := range output.DeliveryStreamNames {
37+
tagParams := &firehose.ListTagsForDeliveryStreamInput{
38+
DeliveryStreamName: deliveryStreamName,
39+
Limit: aws.Int64(50),
40+
}
41+
42+
for {
43+
tagResp, tagErr := svc.ListTagsForDeliveryStream(tagParams)
44+
if tagErr != nil {
45+
return nil, tagErr
46+
}
47+
48+
tags = append(tags, tagResp.Tags...)
49+
if !*tagResp.HasMoreTags {
50+
break
51+
}
52+
53+
tagParams.ExclusiveStartTagKey = tagResp.Tags[len(tagResp.Tags)-1].Key
54+
}
55+
3456
resources = append(resources, &FirehoseDeliveryStream{
3557
svc: svc,
3658
deliveryStreamName: deliveryStreamName,
59+
tags: tags,
3760
})
61+
3862
lastDeliveryStreamName = deliveryStreamName
3963
}
4064

41-
if *output.HasMoreDeliveryStreams == false {
65+
if !*output.HasMoreDeliveryStreams {
4266
break
4367
}
4468

@@ -60,3 +84,13 @@ func (f *FirehoseDeliveryStream) Remove() error {
6084
func (f *FirehoseDeliveryStream) String() string {
6185
return *f.deliveryStreamName
6286
}
87+
88+
func (f *FirehoseDeliveryStream) Properties() types.Properties {
89+
properties := types.NewProperties()
90+
for _, tag := range f.tags {
91+
properties.SetTag(tag.Key, tag.Value)
92+
}
93+
94+
properties.Set("Name", f.deliveryStreamName)
95+
return properties
96+
}

0 commit comments

Comments
 (0)