Skip to content

Commit

Permalink
fix(aws): to not submit request when changes is empty (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
linki committed Apr 3, 2017
1 parent 67eb1d8 commit 7fb84ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions provider/aws.go
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions provider/aws_test.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 7fb84ea

Please sign in to comment.