Skip to content

Commit bffd366

Browse files
Route53ResourceRecordSet: add tags of the parent Hosted Zone (#978)
Add the tags of the parent Hosted Zone with a 'hz' prefix, following a similar pattern used for other resource types. Co-authored-by: Philipp Trulson <[email protected]>
1 parent 7c612f4 commit bffd366

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

resources/route53-resource-records.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Route53ResourceRecordSet struct {
1515
hostedZoneName *string
1616
data *route53.ResourceRecordSet
1717
changeId *string
18+
tags []*route53.Tag
1819
}
1920

2021
func init() {
@@ -49,6 +50,15 @@ func ListResourceRecordsForZone(svc *route53.Route53, zoneId *string, zoneName *
4950
HostedZoneId: zoneId,
5051
}
5152

53+
hostedZoneTags, err := svc.ListTagsForResource(&route53.ListTagsForResourceInput{
54+
ResourceId: zoneId,
55+
ResourceType: aws.String("hostedzone"),
56+
})
57+
58+
if err != nil {
59+
return nil, err
60+
}
61+
5262
resources := make([]Resource, 0)
5363

5464
for {
@@ -63,6 +73,7 @@ func ListResourceRecordsForZone(svc *route53.Route53, zoneId *string, zoneName *
6373
hostedZoneId: zoneId,
6474
hostedZoneName: zoneName,
6575
data: rrs,
76+
tags: hostedZoneTags.ResourceTagSet.Tags,
6677
})
6778
}
6879

@@ -114,9 +125,13 @@ func (r *Route53ResourceRecordSet) Remove() error {
114125
}
115126

116127
func (r *Route53ResourceRecordSet) Properties() types.Properties {
117-
return types.NewProperties().
118-
Set("Name", r.data.Name).
119-
Set("Type", r.data.Type)
128+
properties := types.NewProperties()
129+
for _, tag := range r.tags {
130+
properties.SetTagWithPrefix("hz", tag.Key, tag.Value)
131+
}
132+
properties.Set("Name", r.data.Name)
133+
properties.Set("Type", r.data.Type)
134+
return properties
120135
}
121136

122137
func (r *Route53ResourceRecordSet) String() string {

0 commit comments

Comments
 (0)