forked from gruntwork-io/terratest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ebs.go
31 lines (26 loc) · 749 Bytes
/
ebs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package aws
import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/gruntwork-io/terratest/modules/logger"
)
// DeleteEbsSnapshot deletes the given EBS snapshot
func DeleteEbsSnapshot(t *testing.T, region string, snapshot string) {
err := DeleteEbsSnapshotE(t, region, snapshot)
if err != nil {
t.Fatal(err)
}
}
// DeleteEbsSnapshot deletes the given EBS snapshot
func DeleteEbsSnapshotE(t *testing.T, region string, snapshot string) error {
logger.Logf(t, "Deleting EBS snapshot %s", snapshot)
ec2Client, err := NewEc2ClientE(t, region)
if err != nil {
return err
}
_, err = ec2Client.DeleteSnapshot(&ec2.DeleteSnapshotInput{
SnapshotId: aws.String(snapshot),
})
return err
}