diff --git a/modules/aws/route53.go b/modules/aws/route53.go index d4cfde88d..abb7a56ba 100644 --- a/modules/aws/route53.go +++ b/modules/aws/route53.go @@ -10,14 +10,16 @@ import ( "github.com/stretchr/testify/require" ) -func GetRoute53Record(t *testing.T, hostedZoneID, recordName, awsRegion string) *route53.ResourceRecordSet { - r, err := GetRoute53RecordE(t, hostedZoneID, recordName, awsRegion) +// GetRoute53Record returns a Route 53 Record +func GetRoute53Record(t *testing.T, hostedZoneID, recordName, recordType, awsRegion string) *route53.ResourceRecordSet { + r, err := GetRoute53RecordE(t, hostedZoneID, recordName, recordType, awsRegion) require.NoError(t, err) return r } -func GetRoute53RecordE(t *testing.T, hostedZoneID, recordName, awsRegion string) (record *route53.ResourceRecordSet, err error) { +// GetRoute53RecordE returns a Route 53 Record +func GetRoute53RecordE(t *testing.T, hostedZoneID, recordName, recordType, awsRegion string) (record *route53.ResourceRecordSet, err error) { route53Client, err := NewRoute53ClientE(t, awsRegion) if err != nil { return nil, err @@ -26,7 +28,7 @@ func GetRoute53RecordE(t *testing.T, hostedZoneID, recordName, awsRegion string) o, err := route53Client.ListResourceRecordSets(&route53.ListResourceRecordSetsInput{ HostedZoneId: &hostedZoneID, StartRecordName: &recordName, - StartRecordType: proto.String("A"), + StartRecordType: &recordType, MaxItems: proto.String("1"), }) if err != nil { @@ -44,7 +46,15 @@ func GetRoute53RecordE(t *testing.T, hostedZoneID, recordName, awsRegion string) return } -// NewS3ClientE creates an S3 client. +// NewRoute53ClientE creates a route 53 client. +func NewRoute53Client(t *testing.T, region string) *route53.Route53 { + c, err := NewRoute53ClientE(t, region) + require.NoError(t, err) + + return c +} + +// NewRoute53ClientE creates a route 53 client. func NewRoute53ClientE(t *testing.T, region string) (*route53.Route53, error) { sess, err := NewAuthenticatedSession(region) if err != nil { diff --git a/modules/aws/route53_test.go b/modules/aws/route53_test.go index d61907aed..3f98d3183 100644 --- a/modules/aws/route53_test.go +++ b/modules/aws/route53_test.go @@ -70,15 +70,15 @@ func TestRoute53Record(t *testing.T) { }) t.Run("ExistingRecord", func(t *testing.T) { - route53Record := GetRoute53Record(t, *hostedZone.HostedZone.Id, recordName, region) + route53Record := GetRoute53Record(t, *hostedZone.HostedZone.Id, recordName, *resourceRecordSet.Type, region) require.NotNil(t, route53Record) assert.Equal(t, recordName+".", *route53Record.Name) - assert.Equal(t, "A", *route53Record.Type) + assert.Equal(t, *resourceRecordSet.Type, *route53Record.Type) assert.Equal(t, "127.0.0.1", *route53Record.ResourceRecords[0].Value) }) t.Run("NotExistRecord", func(t *testing.T) { - route53Record, err := GetRoute53RecordE(t, *hostedZone.HostedZone.Id, "ne"+recordName, region) + route53Record, err := GetRoute53RecordE(t, *hostedZone.HostedZone.Id, "ne"+recordName, "A", region) assert.Error(t, err) assert.Nil(t, route53Record) })