getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.6k stars 2.03k forks source link

Bug - Route53 IDs inconsistant with API #8153

Open zkarpinski opened 4 days ago

zkarpinski commented 4 days ago

I'll try to add more info over next few days.

TLDR: Route53's API specs from AWS are inconsistent with the resource IDs. Some return /hostedzone/abcd1234567 others return abc1234567

It appears most apis from AWS only accept the true ID and not the /%resource_type%/ prefix. Take for instance list_tags_for_resources if you provide the full id /hostedzone/abcd1234567 the resource is not found or the ID parameter greater than the allowed character limit for the aws cli. This same API's response returns the shorter resource id 'ResourceTagSets': [{'ResourceType': 'hostedzone', 'ResourceId': 'AVGQ56HKPAQLME0', 'Tags': [{'Key': 'Deploy', 'Value': 'True'}, {'Key': 'Name', 'Value': 'UnitTest'}]}]}

A counter example is list_hosted_zones, it return the longer resource id /hostedzone/abcd1234567

It seems the route53 implementation may need some refactoring. As a short term fix, perhaps we can accept both "ID" styles and handle appropriately? Unfortunately the AWS docs don't show which form is returned...

The issue is you cannot simply take the ID from the create and use it with other api endpoints. You must parse out the ID from the longer form.

@bblommers thoughts?

bblommers commented 3 days ago

Well, that's a pain, and definitely weird behaviour!

As a short term fix, perhaps we can accept both "ID" styles and handle appropriately?

Absolutely, that's probably the best way forward.

If/when we determine the exact rules when short resource ID is used/accepted, and when the long version, we can always think about a more thorough refactor. But for now - maximum flexibility in what Moto accepts is best IMO.