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

add tag support to CloudWatchLogsLogGroup #855

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions resources/cloudwatchlogs-loggroups.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/cloudwatchlogs"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type CloudWatchLogsLogGroup struct {
svc *cloudwatchlogs.CloudWatchLogs
logGroupName *string
tags map[string]*string
}

func init() {
Expand All @@ -30,9 +32,19 @@ func ListCloudWatchLogsLogGroups(sess *session.Session) ([]Resource, error) {
}

for _, logGroup := range output.LogGroups {
tagParams := &cloudwatchlogs.ListTagsLogGroupInput{
LogGroupName: logGroup.LogGroupName,
}

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

resources = append(resources, &CloudWatchLogsLogGroup{
svc: svc,
logGroupName: logGroup.LogGroupName,
tags: tagResp.Tags,
})
}

Expand All @@ -58,3 +70,13 @@ func (f *CloudWatchLogsLogGroup) Remove() error {
func (f *CloudWatchLogsLogGroup) String() string {
return *f.logGroupName
}

func (f *CloudWatchLogsLogGroup) Properties() types.Properties {
properties := types.NewProperties()
for k, v := range f.tags {
properties.SetTag(&k, v)
}
properties.
Set("logGroupName", f.logGroupName)
return properties
}