func (user IAMUser) GetLastAccessKeyDate(svc *iam.Client) time.Time {
	input := &iam.ListAccessKeysInput{
		UserName: aws.String(user.Name),
	}

	result, err := svc.ListAccessKeys(context.TODO(), input)
	if err != nil {
		panic(err)
	}
	var lastaccess time.Time
	for _, key := range result.AccessKeyMetadata {
		keyusage, err := svc.GetAccessKeyLastUsed(context.TODO(), &iam.GetAccessKeyLastUsedInput{
			AccessKeyId: key.AccessKeyId,
		})
		if err != nil {
			panic(err)
		}
		if keyusage.AccessKeyLastUsed != nil && keyusage.AccessKeyLastUsed.LastUsedDate != nil {
			if lastaccess.IsZero() || lastaccess.Before(*keyusage.AccessKeyLastUsed.LastUsedDate) {
				lastaccess = *keyusage.AccessKeyLastUsed.LastUsedDate
			}
		}
	}

	return lastaccess
}
// GetLastAccessKeyDate returns the last date an access key was used
GetLastAccessKeyDate returns the last date an access key was used
// GetLastAccessKeyDate returns the last date an access key was used
func (user IAMUser) GetLastAccessKeyDate(svc *iam.Client) time.Time {
	input := &iam.ListAccessKeysInput{
		UserName: aws.String(user.Name),
	}
	result, err := svc.ListAccessKeys(context.TODO(), input)
	if err != nil {
		panic(err)
	}
	var lastaccess time.Time
	for _, key := range result.AccessKeyMetadata {
		keyusage, err := svc.GetAccessKeyLastUsed(context.TODO(), &iam.GetAccessKeyLastUsedInput{
			AccessKeyId: key.AccessKeyId,
		})
		if err != nil {
			panic(err)
		}
		if keyusage.AccessKeyLastUsed != nil && keyusage.AccessKeyLastUsed.LastUsedDate != nil {
			if lastaccess.IsZero() || lastaccess.Before(*keyusage.AccessKeyLastUsed.LastUsedDate) {
				lastaccess = *keyusage.AccessKeyLastUsed.LastUsedDate
			}
		}
	}
	return lastaccess
}
func ( user IAMUser ) GetLastAccessKeyDate ( svc * iam . Client ) time . Time { input := & iam . ListAccessKeysInput { UserName : aws . String ( user . Name ) , } result , err := svc . ListAccessKeys ( context . TODO ( ) , input ) if err != nil { panic ( err ) } var lastaccess time . Time for _ , key := range result . AccessKeyMetadata { keyusage , err := svc . GetAccessKeyLastUsed ( context . TODO ( ) , & iam . GetAccessKeyLastUsedInput { AccessKeyId : key . AccessKeyId , } ) if err != nil { panic ( err ) } if keyusage . AccessKeyLastUsed != nil && keyusage . AccessKeyLastUsed . LastUsedDate != nil { if lastaccess . IsZero ( ) || lastaccess . Before ( * keyusage . AccessKeyLastUsed . LastUsedDate ) { lastaccess = * keyusage . AccessKeyLastUsed . LastUsedDate } } } return lastaccess }
GetLastAccessKeyDate returns the last date an access key was used
GetLastAccessKeyDate returns the last date an access key was used