diff --git a/provider/aws.go b/provider/aws.go index b9b5d2efb5..039e665455 100644 --- a/provider/aws.go +++ b/provider/aws.go @@ -200,6 +200,11 @@ func (p *AWSProvider) ApplyChanges(zone string, changes *plan.Changes) error { // submitChanges takes a zone and a collection of Changes and sends them as a single transaction. func (p *AWSProvider) submitChanges(zone string, changes []*route53.Change) error { + // return early if there is nothing to change + if len(changes) == 0 { + return nil + } + hostedZone, err := p.Zone(zone) if err != nil { return err diff --git a/provider/aws_test.go b/provider/aws_test.go index 587ec61472..d2ed0513cb 100644 --- a/provider/aws_test.go +++ b/provider/aws_test.go @@ -72,6 +72,10 @@ func (r *Route53APIStub) ChangeResourceRecordSets(input *route53.ChangeResourceR return nil, fmt.Errorf("Hosted zone doesn't exist: %s", aws.StringValue(input.HostedZoneId)) } + if len(input.ChangeBatch.Changes) == 0 { + return nil, fmt.Errorf("ChangeBatch doesn't contain any changes") + } + output := &route53.ChangeResourceRecordSetsOutput{} recordSets, ok := r.recordSets[aws.StringValue(input.HostedZoneId)] if !ok { @@ -483,6 +487,20 @@ func TestAWSApply(t *testing.T) { } } +func TestAWSApplyNoChanges(t *testing.T) { + provider := newAWSProvider(t, false) + + _, err := provider.CreateZone("ext-dns-test.teapot.zalan.do.") + if err != nil { + t.Fatal(err) + } + + err = provider.ApplyChanges("ext-dns-test.teapot.zalan.do.", &plan.Changes{}) + if err != nil { + t.Error(err) + } +} + func TestAWSCreateRecordDryRun(t *testing.T) { provider := newAWSProvider(t, false)