@@ -3,8 +3,6 @@ package resources
3
3
import (
4
4
"context"
5
5
6
- "github.com/gotidy/ptr"
7
-
8
6
"github.com/aws/aws-sdk-go/service/ec2"
9
7
10
8
"github.com/ekristen/libnuke/pkg/registry"
@@ -40,26 +38,28 @@ func (l *EC2AddressLister) List(_ context.Context, o interface{}) ([]resource.Re
40
38
resources := make ([]resource.Resource , 0 )
41
39
for _ , out := range resp .Addresses {
42
40
resources = append (resources , & EC2Address {
43
- svc : svc ,
44
- eip : out ,
45
- id : ptr . ToString ( out .AllocationId ) ,
46
- ip : ptr . ToString ( out .PublicIp ) ,
41
+ svc : svc ,
42
+ AllocationID : out . AllocationId ,
43
+ PublicIP : out .PublicIp ,
44
+ Tags : out .Tags ,
47
45
})
48
46
}
49
47
50
48
return resources , nil
51
49
}
52
50
53
51
type EC2Address struct {
54
- svc * ec2.EC2
55
- eip * ec2.Address
56
- id string
57
- ip string
52
+ svc * ec2.EC2
53
+ AllocationID * string
54
+ PublicIP * string
55
+ NetworkBorderGroup * string
56
+ Tags []* ec2.Tag
58
57
}
59
58
60
- func (e * EC2Address ) Remove (_ context.Context ) error {
61
- _ , err := e .svc .ReleaseAddress (& ec2.ReleaseAddressInput {
62
- AllocationId : & e .id ,
59
+ func (r * EC2Address ) Remove (_ context.Context ) error {
60
+ _ , err := r .svc .ReleaseAddress (& ec2.ReleaseAddressInput {
61
+ AllocationId : r .AllocationID ,
62
+ NetworkBorderGroup : r .NetworkBorderGroup ,
63
63
})
64
64
if err != nil {
65
65
return err
@@ -68,15 +68,10 @@ func (e *EC2Address) Remove(_ context.Context) error {
68
68
return nil
69
69
}
70
70
71
- func (e * EC2Address ) Properties () types.Properties {
72
- properties := types .NewProperties ()
73
- for _ , tagValue := range e .eip .Tags {
74
- properties .SetTag (tagValue .Key , tagValue .Value )
75
- }
76
- properties .Set ("AllocationID" , e .id )
77
- return properties
71
+ func (r * EC2Address ) Properties () types.Properties {
72
+ return types .NewPropertiesFromStruct (r )
78
73
}
79
74
80
- func (e * EC2Address ) String () string {
81
- return e . ip
75
+ func (r * EC2Address ) String () string {
76
+ return * r . PublicIP
82
77
}
0 commit comments