From cf1e23754a173a54e144339869bdba794e51fc19 Mon Sep 17 00:00:00 2001 From: hmalphettes Date: Sun, 12 May 2019 09:30:30 +0800 Subject: [PATCH] Enable tags for EC2 DHCP Options --- resources/ec2-dhcp-options.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/resources/ec2-dhcp-options.go b/resources/ec2-dhcp-options.go index ddd3162f..3ccdd552 100644 --- a/resources/ec2-dhcp-options.go +++ b/resources/ec2-dhcp-options.go @@ -3,11 +3,13 @@ package resources import ( "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 EC2DHCPOption struct { - svc *ec2.EC2 - id *string + svc *ec2.EC2 + id *string + tags []*ec2.Tag } func init() { @@ -26,8 +28,9 @@ func ListEC2DHCPOptions(sess *session.Session) ([]Resource, error) { for _, out := range resp.DhcpOptions { resources = append(resources, &EC2DHCPOption{ - svc: svc, - id: out.DhcpOptionsId, + svc: svc, + id: out.DhcpOptionsId, + tags: out.Tags, }) } @@ -47,6 +50,14 @@ func (e *EC2DHCPOption) Remove() error { return nil } +func (e *EC2DHCPOption) Properties() types.Properties { + properties := types.NewProperties() + for _, tagValue := range e.tags { + properties.SetTag(tagValue.Key, tagValue.Value) + } + return properties +} + func (e *EC2DHCPOption) String() string { return *e.id }