From 50fa8fae6bc0b4d0150ac069e575dfd8996724e1 Mon Sep 17 00:00:00 2001 From: Ivan Morgun Date: Thu, 1 Dec 2022 00:17:12 +0300 Subject: [PATCH] Add CreateDate and LastUsedDate for IAMRole resource --- resources/iam-roles.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/iam-roles.go b/resources/iam-roles.go index eaf6b287a..14ba91d9f 100644 --- a/resources/iam-roles.go +++ b/resources/iam-roles.go @@ -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" @@ -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)