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

Commit 4f8848f

Browse files
authored
feat: add missing tags for iam resources (#731)
* feat: add tags for iam user * fix: propagate tags for iam user * chore(iam-role-policy): reorder imports * feat(iam-instance-profile): add tags
1 parent 59560b3 commit 4f8848f

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

resources/iam-instance-profiles.go

+14
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package resources
33
import (
44
"github.com/aws/aws-sdk-go/aws/session"
55
"github.com/aws/aws-sdk-go/service/iam"
6+
"github.com/rebuy-de/aws-nuke/pkg/types"
67
)
78

89
type IAMInstanceProfile struct {
910
svc *iam.IAM
1011
name string
12+
tags []*iam.Tag
1113
}
1214

1315
func init() {
@@ -29,6 +31,7 @@ func ListIAMInstanceProfiles(sess *session.Session) ([]Resource, error) {
2931
resources = append(resources, &IAMInstanceProfile{
3032
svc: svc,
3133
name: *out.InstanceProfileName,
34+
tags: out.Tags,
3235
})
3336
}
3437

@@ -56,3 +59,14 @@ func (e *IAMInstanceProfile) Remove() error {
5659
func (e *IAMInstanceProfile) String() string {
5760
return e.name
5861
}
62+
63+
func (e *IAMInstanceProfile) Properties() types.Properties {
64+
properties := types.NewProperties()
65+
properties.Set("Name", e.name)
66+
67+
for _, tag := range e.tags {
68+
properties.SetTag(tag.Key, tag.Value)
69+
}
70+
71+
return properties
72+
}

resources/iam-role-policy.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package resources
22

33
import (
44
"fmt"
5-
"github.com/sirupsen/logrus"
65
"strings"
76

7+
"github.com/sirupsen/logrus"
8+
89
"github.com/aws/aws-sdk-go/aws"
910
"github.com/aws/aws-sdk-go/aws/session"
1011
"github.com/aws/aws-sdk-go/service/iam"

resources/iam-users.go

+14
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package resources
33
import (
44
"github.com/aws/aws-sdk-go/aws/session"
55
"github.com/aws/aws-sdk-go/service/iam"
6+
"github.com/rebuy-de/aws-nuke/pkg/types"
67
)
78

89
type IAMUser struct {
910
svc *iam.IAM
1011
name string
12+
tags []*iam.Tag
1113
}
1214

1315
func init() {
@@ -27,6 +29,7 @@ func ListIAMUsers(sess *session.Session) ([]Resource, error) {
2729
resources = append(resources, &IAMUser{
2830
svc: svc,
2931
name: *out.UserName,
32+
tags: out.Tags,
3033
})
3134
}
3235

@@ -47,3 +50,14 @@ func (e *IAMUser) Remove() error {
4750
func (e *IAMUser) String() string {
4851
return e.name
4952
}
53+
54+
func (e *IAMUser) Properties() types.Properties {
55+
properties := types.NewProperties()
56+
properties.Set("Name", e.name)
57+
58+
for _, tag := range e.tags {
59+
properties.SetTag(tag.Key, tag.Value)
60+
}
61+
62+
return properties
63+
}

0 commit comments

Comments
 (0)