Skip to content

Commit

Permalink
Merge pull request #558 from overmindtech/add-route53-links
Browse files Browse the repository at this point in the history
Added additional DNS links to Route53 record
  • Loading branch information
dylanratcliffe authored Aug 1, 2024
2 parents 55b0047 + a052ab1 commit f5ec45c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs-data/route53-resource-record-set.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"terraformMethod": "SEARCH",
"terraformScope": "*",
"links": [
"dns"
"dns",
"route53-health-check"
]
}
36 changes: 36 additions & 0 deletions sources/route53/resource_record_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,42 @@ func resourceRecordSetItemMapper(scope string, awsItem *types.ResourceRecordSet)
}
}

for _, record := range awsItem.ResourceRecords {
if record.Value != nil {
// +overmind:link dns
item.LinkedItemQueries = append(item.LinkedItemQueries, &sdp.LinkedItemQuery{
Query: &sdp.Query{
Type: "dns",
Method: sdp.QueryMethod_SEARCH,
Query: *record.Value,
Scope: "global",
},
BlastPropagation: &sdp.BlastPropagation{
// DNS aliases links
In: true,
Out: true,
},
})
}
}

if awsItem.HealthCheckId != nil {
// +overmind:link route53-health-check
item.LinkedItemQueries = append(item.LinkedItemQueries, &sdp.LinkedItemQuery{
Query: &sdp.Query{
Type: "route53-health-check",
Method: sdp.QueryMethod_GET,
Query: *awsItem.HealthCheckId,
Scope: scope,
},
BlastPropagation: &sdp.BlastPropagation{
// Health check links tightly
In: true,
Out: true,
},
})
}

return &item, nil
}

Expand Down
50 changes: 43 additions & 7 deletions sources/route53/resource_record_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,28 @@ func TestResourceRecordSetItemMapper(t *testing.T) {
Name: sources.PtrString("overmind-demo.com."),
Type: types.RRTypeNs,
TTL: sources.PtrInt64(172800),
GeoProximityLocation: &types.GeoProximityLocation{
AWSRegion: sources.PtrString("us-east-1"),
Bias: sources.PtrInt32(100),
Coordinates: &types.Coordinates{},
LocalZoneGroup: sources.PtrString("group"),
},
ResourceRecords: []types.ResourceRecord{
{
Value: sources.PtrString("ns-1673.awsdns-17.co.uk."),
Value: sources.PtrString("ns-1673.awsdns-17.co.uk."), // link
},
{
Value: sources.PtrString("ns-1505.awsdns-60.org."),
Value: sources.PtrString("ns-1505.awsdns-60.org."), // link
},
{
Value: sources.PtrString("ns-955.awsdns-55.net."),
Value: sources.PtrString("ns-955.awsdns-55.net."), // link
},
{
Value: sources.PtrString("ns-276.awsdns-34.com."),
Value: sources.PtrString("ns-276.awsdns-34.com."), // link
},
},
AliasTarget: &types.AliasTarget{
DNSName: sources.PtrString("dnsName"),
DNSName: sources.PtrString("foo.bar.com"), // link
EvaluateTargetHealth: true,
HostedZoneId: sources.PtrString("id"),
},
Expand All @@ -43,7 +49,7 @@ func TestResourceRecordSetItemMapper(t *testing.T) {
CountryCode: sources.PtrString("GB"),
SubdivisionCode: sources.PtrString("ENG"),
},
HealthCheckId: sources.PtrString("id"),
HealthCheckId: sources.PtrString("id"), // link
MultiValueAnswer: sources.PtrBool(true),
Region: types.ResourceRecordSetRegionApEast1,
SetIdentifier: sources.PtrString("identifier"),
Expand All @@ -65,9 +71,39 @@ func TestResourceRecordSetItemMapper(t *testing.T) {
{
ExpectedType: "dns",
ExpectedMethod: sdp.QueryMethod_SEARCH,
ExpectedQuery: "dnsName",
ExpectedQuery: "foo.bar.com",
ExpectedScope: "global",
},
{
ExpectedType: "dns",
ExpectedMethod: sdp.QueryMethod_SEARCH,
ExpectedQuery: "ns-1673.awsdns-17.co.uk.",
ExpectedScope: "global",
},
{
ExpectedType: "dns",
ExpectedMethod: sdp.QueryMethod_SEARCH,
ExpectedQuery: "ns-1505.awsdns-60.org.",
ExpectedScope: "global",
},
{
ExpectedType: "dns",
ExpectedMethod: sdp.QueryMethod_SEARCH,
ExpectedQuery: "ns-955.awsdns-55.net.",
ExpectedScope: "global",
},
{
ExpectedType: "dns",
ExpectedMethod: sdp.QueryMethod_SEARCH,
ExpectedQuery: "ns-276.awsdns-34.com.",
ExpectedScope: "global",
},
{
ExpectedType: "route53-health-check",
ExpectedMethod: sdp.QueryMethod_GET,
ExpectedQuery: "id",
ExpectedScope: "foo",
},
}

tests.Execute(t, item)
Expand Down

0 comments on commit f5ec45c

Please sign in to comment.