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

Commit

Permalink
Adding tag support for FirehoseDeliveryStreams (#1088)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MikeSchouw authored Aug 25, 2023
1 parent 5342982 commit 7771ef6
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion resources/firehose-deliverystreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/firehose"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type FirehoseDeliveryStream struct {
svc *firehose.Firehose
deliveryStreamName *string
tags []*firehose.Tag
}

func init() {
Expand All @@ -18,6 +20,7 @@ func init() {
func ListFirehoseDeliveryStreams(sess *session.Session) ([]Resource, error) {
svc := firehose.New(sess)
resources := []Resource{}
tags := []*firehose.Tag{}
var lastDeliveryStreamName *string

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

for _, deliveryStreamName := range output.DeliveryStreamNames {
tagParams := &firehose.ListTagsForDeliveryStreamInput{
DeliveryStreamName: deliveryStreamName,
Limit: aws.Int64(50),
}

for {
tagResp, tagErr := svc.ListTagsForDeliveryStream(tagParams)
if tagErr != nil {
return nil, tagErr
}

tags = append(tags, tagResp.Tags...)
if !*tagResp.HasMoreTags {
break
}

tagParams.ExclusiveStartTagKey = tagResp.Tags[len(tagResp.Tags)-1].Key
}

resources = append(resources, &FirehoseDeliveryStream{
svc: svc,
deliveryStreamName: deliveryStreamName,
tags: tags,
})

lastDeliveryStreamName = deliveryStreamName
}

if *output.HasMoreDeliveryStreams == false {
if !*output.HasMoreDeliveryStreams {
break
}

Expand All @@ -60,3 +84,13 @@ func (f *FirehoseDeliveryStream) Remove() error {
func (f *FirehoseDeliveryStream) String() string {
return *f.deliveryStreamName
}

func (f *FirehoseDeliveryStream) Properties() types.Properties {
properties := types.NewProperties()
for _, tag := range f.tags {
properties.SetTag(tag.Key, tag.Value)
}

properties.Set("Name", f.deliveryStreamName)
return properties
}

0 comments on commit 7771ef6

Please sign in to comment.