Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS: Extend aws_handle_regions to cover IAM get functions #1227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alowde-ps
Copy link

This change adds the aws_handle_regions decorator to the IAM get functions so that we can safely skip over API calls that the caller is unauthorized to make.

To support this the aws_handle_functions decorator has been extended to return an empty type based on the signature of the calling function, and the AWSGetFunc type is now a union of Callable[..., List] and Callable[..., Dict[Any, Any].

This has been tested in action and passes mypy validation of the type changes.

@ramonpetgrave64
Copy link
Collaborator

@alowde-ps While you're getting the tests to work, I've been thinking a bit more on this. What you're proposing sounds like a best-effort mode, which I think is a significant shift to how we've done things before. Personally I'd rather this be tied into our existing cli switch --aws-best-effort-mode somehow. wdyt @achantavy

Also, I see that you put the decorator on functions like get_group_managed_policy_data(boto3_session: boto3.session.Session, group_list: List[Dict]) which are meant to fetch for many items in the provided list. From our conversation, I think your use-case was when any single item is Denied. In this case, it's less appropriate to do @handle_regions for the entire list of items, and better to refactor the individual fetches into a separate function to receive the decorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants