aws / aws-sdk-go

AWS SDK for the Go programming language.
http://aws.amazon.com/sdk-for-go/
Apache License 2.0
8.64k stars 2.07k forks source link

Return a helpful error type when duplicate calls to route53resolver.AssociateResolverRule are made #4030

Closed michaelfinch closed 3 years ago

michaelfinch commented 3 years ago

Is your feature request related to a problem? Please describe. I have a lambda that I'm trying to make idempotent. The lambda is triggered by a cloudwatch RAM sharing event, and the first thing it does is call route53resolver.AssociateResolverRule. I'm running into issues where the lambda is being invoked multiple times, and while the first call to route53resolver.AssociateResolverRule succeeds, all subsequent calls fail and return a ErrCodeInvalidRequestException error with the message InvalidRequestException: [RSLVR-00802] Cannot associate rules with same domain name with same VPC. Conflict with resolver rule "${the-resolver-rule-id}": errorString". In order to make the lambda idempotent I have to ignore this error. Unfortunately, though, the error is too generic to ignore because it sounds like it could easily indicate other problems with a request.

Describe the solution you'd like I'd like for duplicate calls to route53resolver.AssociateResolverRule to return a more specific/useful error type, such as a ErrCodeResourceExistsException. That way it would be easy and safe to ignore that type of error.

Describe alternatives you've considered Parsing the error message, which is terrible.

Additional context As I'm sure you know, the same lambda can be invoked multiple times asynchronously. It's not safe for my lambda to first check to see if a resolver rule association requests exists before trying to create it, because that would be prone to race conditions.

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.