Repository: zalando-stups/senza

Issue:
Only call API for Route53 config if there is changes to be made
Only call AWS API when there is actual changes to be made.

Users reporting this exception:
```
     raise ParamValidationError(report=report.generate_report())
 botocore.exceptions.ParamValidationError: Parameter validation failed:
 Invalid length for parameter ChangeBatch.Changes, value: 0, valid range: 1-inf
```

Error comes from https://github.com/zalando-stups/senza/blob/master/senza/manaus/route53.py#L114-L115

Discussion:

Patch:
diff --git a/senza/manaus/route53.py b/senza/manaus/route53.py
index 0075eb0..6aab215 100644
--- a/senza/manaus/route53.py
+++ b/senza/manaus/route53.py
@@ -112,8 +112,9 @@ class Route53HostedZone:
                       'ResourceRecordSet': record.boto_dict}
             change_batch['Changes'].append(change)
 
-        client.change_resource_record_sets(HostedZoneId=self.id,
-                                           ChangeBatch=change_batch)
+        if change_batch['Changes']:
+            client.change_resource_record_sets(HostedZoneId=self.id,
+                                               ChangeBatch=change_batch)
 
         return change_batch
 


Test patch:
diff --git a/tests/test_manaus/test_route53.py b/tests/test_manaus/test_route53.py
index 2441ba1..24c5441 100644
--- a/tests/test_manaus/test_route53.py
+++ b/tests/test_manaus/test_route53.py
@@ -209,6 +209,12 @@ def test_hosted_zone_upsert(monkeypatch):
         ChangeBatch={'Changes': expected_changes,
                      'Comment': 'test'})
 
+    m_client.change_resource_record_sets.reset_mock()
+    change_batch2 = hosted_zone.upsert([], comment="test")
+    assert change_batch2['Comment'] == "test"
+    assert change_batch2['Changes'] == []
+    m_client.change_resource_record_sets.assert_not_called()
+
 
 def test_hosted_zone_create(monkeypatch):
     m_client = MagicMock()