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

Commit

Permalink
feat: add missing tags for iam resources (#731)
Browse files Browse the repository at this point in the history
* feat: add tags for iam user

* fix: propagate tags for iam user

* chore(iam-role-policy): reorder imports

* feat(iam-instance-profile): add tags
  • Loading branch information
mavogel authored Jan 21, 2022
1 parent 59560b3 commit 4f8848f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions resources/iam-instance-profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package resources
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type IAMInstanceProfile struct {
svc *iam.IAM
name string
tags []*iam.Tag
}

func init() {
Expand All @@ -29,6 +31,7 @@ func ListIAMInstanceProfiles(sess *session.Session) ([]Resource, error) {
resources = append(resources, &IAMInstanceProfile{
svc: svc,
name: *out.InstanceProfileName,
tags: out.Tags,
})
}

Expand Down Expand Up @@ -56,3 +59,14 @@ func (e *IAMInstanceProfile) Remove() error {
func (e *IAMInstanceProfile) String() string {
return e.name
}

func (e *IAMInstanceProfile) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", e.name)

for _, tag := range e.tags {
properties.SetTag(tag.Key, tag.Value)
}

return properties
}
3 changes: 2 additions & 1 deletion resources/iam-role-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package resources

import (
"fmt"
"github.com/sirupsen/logrus"
"strings"

"github.com/sirupsen/logrus"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
Expand Down
14 changes: 14 additions & 0 deletions resources/iam-users.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package resources
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type IAMUser struct {
svc *iam.IAM
name string
tags []*iam.Tag
}

func init() {
Expand All @@ -27,6 +29,7 @@ func ListIAMUsers(sess *session.Session) ([]Resource, error) {
resources = append(resources, &IAMUser{
svc: svc,
name: *out.UserName,
tags: out.Tags,
})
}

Expand All @@ -47,3 +50,14 @@ func (e *IAMUser) Remove() error {
func (e *IAMUser) String() string {
return e.name
}

func (e *IAMUser) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", e.name)

for _, tag := range e.tags {
properties.SetTag(tag.Key, tag.Value)
}

return properties
}

0 comments on commit 4f8848f

Please sign in to comment.