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

Add resource URL handler #9047

Merged

Conversation

jaydhulia
Copy link
Collaborator

Add a handler that returns a ConsoleMe URL suffix, given an ARN. To be used by Weep for allowing users to open a resource page by providing an ARN. This is linked to PR Netflix/weep#61 for weep

@@ -726,147 +738,210 @@ async def get_url_for_resource(
region = await get_region_for_arn(arn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice stuff!

I think we need to handle the situation where account_id is None here. This function was generally only used for known resources previously. But if we pass in an S3 bucket ARN for an unknown resource, I'd expect this to be None.

We should try to adhere to the relatively new WebResponse model (This is in consoleme.models) and return a 404 with a description. Weep may need to be updated to show the error form the backend

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good call, updated the PR to reflect the changes!

return resource_name.split("/")[0]
return ""


async def get_url_for_resource(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be cool to use this functionality within ConsoleMe as well! Future feature?

IE: www.consoleme.url/resource/arn:aws:s3:::bucket_name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh I like this idea a lot; that would be super cool!

@patricksanders
Copy link
Collaborator

@jaydhulia Can you please add this new endpoint to the Swagger spec?

@jaydhulia
Copy link
Collaborator Author

@patricksanders Added the endpoint to the Swagger spec!

class GetResourceURLHandler(BaseMtlsHandler):
"""consoleme CLI resource URL handler. Parameters accepted: arn."""

def check_xsrf_cookie(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need check_xsrf_cookie here since we're not performing a PUT/POST.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, looks like I was able to push to this branch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I checked the Allow edits and access to secrets by maintainers box when making the PR 😄

@castrapel castrapel merged commit 90d7a7f into Netflix:master Apr 7, 2021
@castrapel
Copy link
Contributor

Thanks for this feature Jay!!

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.

3 participants