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

Commit

Permalink
Route53ResourceRecordSet: add tags of the parent Hosted Zone
Browse files Browse the repository at this point in the history
Add the tags of the parent Hosted Zone with a 'hz' prefix, following
a similar pattern used for other resource types.
  • Loading branch information
andreadecorte committed Aug 21, 2023
1 parent f4030b9 commit 8cd1f14
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions resources/route53-resource-records.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Route53ResourceRecordSet struct {
hostedZoneName *string
data *route53.ResourceRecordSet
changeId *string
tags []*route53.Tag
}

func init() {
Expand Down Expand Up @@ -49,6 +50,15 @@ func ListResourceRecordsForZone(svc *route53.Route53, zoneId *string, zoneName *
HostedZoneId: zoneId,
}

hostedZoneTags, err := svc.ListTagsForResource(&route53.ListTagsForResourceInput{
ResourceId: zoneId,
ResourceType: aws.String("hostedzone"),
})

if err != nil {
return nil, err
}

resources := make([]Resource, 0)

for {
Expand All @@ -63,6 +73,7 @@ func ListResourceRecordsForZone(svc *route53.Route53, zoneId *string, zoneName *
hostedZoneId: zoneId,
hostedZoneName: zoneName,
data: rrs,
tags: hostedZoneTags.ResourceTagSet.Tags,
})
}

Expand Down Expand Up @@ -114,9 +125,13 @@ func (r *Route53ResourceRecordSet) Remove() error {
}

func (r *Route53ResourceRecordSet) Properties() types.Properties {
return types.NewProperties().
Set("Name", r.data.Name).
Set("Type", r.data.Type)
properties := types.NewProperties()
for _, tag := range r.tags {
properties.SetTagWithPrefix("hz", tag.Key, tag.Value)
}
properties.Set("Name", r.data.Name)
properties.Set("Type", r.data.Type)
return properties
}

func (r *Route53ResourceRecordSet) String() string {
Expand Down

0 comments on commit 8cd1f14

Please sign in to comment.