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

Role session name might be too long #9156

Open
avishayil opened this issue Jun 29, 2021 · 2 comments
Open

Role session name might be too long #9156

avishayil opened this issue Jun 29, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@avishayil
Copy link
Contributor

Describe the bug
I encountered some cases where the ConsoleMe user is long, and because of that the session name exceeds the 64 character limit, since it relies on the user name.

To Reproduce
Steps to reproduce the behavior:

  1. Create a long username (I.E [email protected])
  2. Try to create a new role using that username
  3. Error will be encountered:
    Exception occurred cloning role: An error occurred (ValidationError) when calling the AssumeRole operation: 1 validation error detected: Value 'create_role_consoleme_admin@verylongsubdomainname.verylongdomainname.com' at 'roleSessionName' failed to satisfy constraint: Member must have length less than or equal to 64
    

From the aws.py lib:

    iam_client = await sync_to_async(boto3_cached_conn)(
        "iam",
        service_type="client",
        account_number=create_model.account_id,
        region=config.region,
        assume_role=config.get("policies.role_name"),
        session_name="create_role_" + username,
        retry_max_attempts=2,
    )

Expected behavior
A role will be created successfully as expected.

I suggest to find another mechanism, such as extracting the username from the domain, to decrease the chances of encountering such error.

@patricksanders
Copy link
Collaborator

Thanks for the report! This is an interesting scenario.

It looks like the issue is unrelated to the particular action (creating a role), but rather a problem with long user IDs for any AWS action that needs to be attributed to a particular user. Extracting the username from the email address isn't quite the right solution, since that can cause collisions or ambiguities in multi-domain environments. I wonder if we could make this configurable.

@castrapel
Copy link
Contributor

PR submitted to address this: #9254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants