diff --git a/moto/route53/responses.py b/moto/route53/responses.py index 3cd848607..f565bb680 100644 --- a/moto/route53/responses.py +++ b/moto/route53/responses.py @@ -55,7 +55,11 @@ def rrset_response(request, full_url, headers): action = value['Action'] record_set = value['ResourceRecordSet'] if action == 'CREATE': - record_set['ResourceRecords'] = [x['Value'] for x in record_set['ResourceRecords'].values()] + resource_records = record_set['ResourceRecords'].values()[0] + if not isinstance(resource_records, list): + # Depending on how many records there are, this may or may not be a list + resource_records = [resource_records] + record_set['ResourceRecords'] = [x['Value'] for x in resource_records] the_zone.add_rrset(record_set) elif action == "DELETE": if 'SetIdentifier' in record_set: diff --git a/tests/test_route53/test_route53.py b/tests/test_route53/test_route53.py index 9af3a5f09..10f2ba81c 100644 --- a/tests/test_route53/test_route53.py +++ b/tests/test_route53/test_route53.py @@ -92,6 +92,23 @@ def test_rrset(): rrsets.should.have.length_of(0) +@mock_route53 +def test_rrset_with_multiple_values(): + conn = boto.connect_route53('the_key', 'the_secret') + zone = conn.create_hosted_zone("testdns.aws.com") + zoneid = zone["CreateHostedZoneResponse"]["HostedZone"]["Id"].split("/")[-1] + + changes = ResourceRecordSets(conn, zoneid) + change = changes.add_change("CREATE", "foo.bar.testdns.aws.com", "A") + change.add_value("1.2.3.4") + change.add_value("5.6.7.8") + changes.commit() + + rrsets = conn.get_all_rrsets(zoneid, type="A") + rrsets.should.have.length_of(1) + set(rrsets[0].resource_records).should.equal(set(['1.2.3.4', '5.6.7.8'])) + + @mock_route53 def test_create_health_check(): conn = boto.connect_route53('the_key', 'the_secret')