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

Commit

Permalink
Add ec2 snapshot starttime (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaseFreeman17 authored Jan 3, 2022
1 parent fc5ade6 commit 3b7d60a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions resources/ec2-snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ package resources

import (
"fmt"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type EC2Snapshot struct {
svc *ec2.EC2
id string
tags []*ec2.Tag
svc *ec2.EC2
id string
startTime *time.Time
tags []*ec2.Tag
}

func init() {
Expand All @@ -33,9 +36,10 @@ func ListEC2Snapshots(sess *session.Session) ([]Resource, error) {
resources := make([]Resource, 0)
for _, out := range resp.Snapshots {
resources = append(resources, &EC2Snapshot{
svc: svc,
id: *out.SnapshotId,
tags: out.Tags,
svc: svc,
id: *out.SnapshotId,
startTime: out.StartTime,
tags: out.Tags,
})
}

Expand All @@ -44,6 +48,8 @@ func ListEC2Snapshots(sess *session.Session) ([]Resource, error) {

func (e *EC2Snapshot) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("StartTime", e.startTime.Format(time.RFC3339))

for _, tagValue := range e.tags {
properties.Set(fmt.Sprintf("tag:%v", *tagValue.Key), tagValue.Value)
}
Expand Down

0 comments on commit 3b7d60a

Please sign in to comment.