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

Add CreateDate and LastUsedDate for IAMRole resource #887

Merged
merged 1 commit into from
Dec 6, 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
7 changes: 7 additions & 0 deletions resources/iam-roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resources
import (
"fmt"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
Expand Down Expand Up @@ -91,6 +92,12 @@ func (role *IAMRole) Properties() types.Properties {
for _, tagValue := range role.role.Tags {
properties.SetTag(tagValue.Key, tagValue.Value)
}
properties.Set("CreateDate", role.role.CreateDate.Format(time.RFC3339))
if role.role.RoleLastUsed.LastUsedDate == nil {
properties.Set("LastUsedDate", role.role.CreateDate.Format(time.RFC3339))
} else {
properties.Set("LastUsedDate", role.role.RoleLastUsed.LastUsedDate.Format(time.RFC3339))
}
properties.
Set("Name", role.name).
Set("Path", role.path)
Expand Down