diff --git a/resources/elasticache-replicationgroups.go b/resources/elasticache-replicationgroups.go index b677263e4..fc382be94 100644 --- a/resources/elasticache-replicationgroups.go +++ b/resources/elasticache-replicationgroups.go @@ -1,14 +1,18 @@ package resources import ( + "time" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/elasticache" + "github.com/rebuy-de/aws-nuke/v2/pkg/types" ) type ElasticacheReplicationGroup struct { - svc *elasticache.ElastiCache - groupID *string + svc *elasticache.ElastiCache + groupID *string + createTime *time.Time } func init() { @@ -29,8 +33,9 @@ func ListElasticacheReplicationGroups(sess *session.Session) ([]Resource, error) for _, replicationGroup := range resp.ReplicationGroups { resources = append(resources, &ElasticacheReplicationGroup{ - svc: svc, - groupID: replicationGroup.ReplicationGroupId, + svc: svc, + groupID: replicationGroup.ReplicationGroupId, + createTime: replicationGroup.ReplicationGroupCreateTime, }) } @@ -44,6 +49,18 @@ func ListElasticacheReplicationGroups(sess *session.Session) ([]Resource, error) return resources, nil } +func (i *ElasticacheReplicationGroup) Properties() types.Properties { + properties := types.NewProperties() + + properties.Set("ID", i.groupID) + + if i.createTime != nil { + properties.Set("CreateTime", i.createTime.Format(time.RFC3339)) + } + + return properties +} + func (i *ElasticacheReplicationGroup) Remove() error { params := &elasticache.DeleteReplicationGroupInput{ ReplicationGroupId: i.groupID, diff --git a/resources/iam-user-access-keys.go b/resources/iam-user-access-keys.go index 11e837cec..250e9d6eb 100644 --- a/resources/iam-user-access-keys.go +++ b/resources/iam-user-access-keys.go @@ -2,6 +2,7 @@ package resources import ( "fmt" + "time" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/iam" @@ -11,6 +12,7 @@ import ( type IAMUserAccessKey struct { svc *iam.IAM accessKeyId string + createDate *time.Time userName string status string userTags []*iam.Tag @@ -47,6 +49,7 @@ func ListIAMUserAccessKeys(sess *session.Session) ([]Resource, error) { resources = append(resources, &IAMUserAccessKey{ svc: svc, accessKeyId: *meta.AccessKeyId, + createDate: meta.CreateDate, userName: *meta.UserName, status: *meta.Status, userTags: userTags.Tags, @@ -75,6 +78,10 @@ func (e *IAMUserAccessKey) Properties() types.Properties { properties.Set("UserName", e.userName) properties.Set("AccessKeyID", e.accessKeyId) + if e.createDate != nil { + properties.Set("CreateDate", e.createDate.Format(time.RFC3339)) + } + for _, tag := range e.userTags { properties.SetTag(tag.Key, tag.Value) } diff --git a/resources/iam-users.go b/resources/iam-users.go index 67a34c16a..7995fc0ae 100644 --- a/resources/iam-users.go +++ b/resources/iam-users.go @@ -1,6 +1,8 @@ package resources import ( + "time" + "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/iam" "github.com/rebuy-de/aws-nuke/v2/pkg/types" @@ -8,9 +10,11 @@ import ( ) type IAMUser struct { - svc *iam.IAM - name string - tags []*iam.Tag + svc *iam.IAM + name string + tags []*iam.Tag + createDate *time.Time + passwordLastUsed *time.Time } func init() { @@ -37,9 +41,11 @@ func ListIAMUsers(sess *session.Session) ([]Resource, error) { continue } resources = append(resources, &IAMUser{ - svc: svc, - name: *out.UserName, - tags: user.Tags, + svc: svc, + name: *user.UserName, + tags: user.Tags, + createDate: user.CreateDate, + passwordLastUsed: user.PasswordLastUsed, }) } return true @@ -70,6 +76,13 @@ func (e *IAMUser) Properties() types.Properties { properties := types.NewProperties() properties.Set("Name", e.name) + if e.createDate != nil { + properties.Set("CreateDate", e.createDate.Format(time.RFC3339)) + } + if e.passwordLastUsed != nil { + properties.Set("PasswordLastUsed", e.passwordLastUsed.Format(time.RFC3339)) + } + for _, tag := range e.tags { properties.SetTag(tag.Key, tag.Value) }