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

The table does not have the specified index: RoleName #58

Closed
Mortinke opened this issue Nov 23, 2017 · 2 comments · Fixed by #59
Closed

The table does not have the specified index: RoleName #58

Mortinke opened this issue Nov 23, 2017 · 2 comments · Fixed by #59

Comments

@Mortinke
Copy link

Environment

(venv) ubuntu@***************:/usr/local/src/repokid$ python --version
Python 2.7.12
(venv) ubuntu@***************:/usr/local/src/repokid$ cat /etc/issue
Ubuntu 16.04.2 LTS \n \l

(venv) ubuntu@***************:/usr/local/src/repokid$ git show
commit 9dc9403b6659f97ba24adaf44413bb1d92e01a30
Author: Travis McPeak <tmcpeak@netflix.com>
Date:   Mon Nov 20 10:40:44 2017 -0800

    Change Dispatcher to show perm count

diff --git a/repokid/dispatcher/__init__.py b/repokid/dispatcher/__init__.py
index 89459f9..6321dce 100644
--- a/repokid/dispatcher/__init__.py
+++ b/repokid/dispatcher/__init__.py
@@ -5,6 +5,7 @@ import time
 from repokid import CONFIG
 import repokid.cli.repokid_cli as cli
 import repokid.utils.dynamo as dynamo
+import repokid.utils.roledata as roledata

 ResponderReturn = namedtuple('ResponderReturn', 'successful, return_message')

@@ -45,7 +46,8 @@ def list_role_rollbacks(dynamo_table, message):
         role_data = dynamo.get_role_data(dynamo_table, role_id, fields=['Policies'])
         return_val = 'Restorable versions for role {} in account {}\n'.format(message.role_name, message.account)
         for index, policy_version in enumerate(role_data['Policies']):
-            return_val += '({:>3}):  {:<5}     {:<15}  {}\n'.format(index, len(str(policy_version['Policy'])),
+            policy_permissions = roledata._get_permissions_in_policy(policy_version['Policy'])
+            return_val += '({:>3}):  {:<5}     {:<15}  {}\n'.format(index, len(policy_permissions),
                                                                     policy_version['Discovered'],
                                                                     policy_version['Source'])
         return ResponderReturn(successful=True, return_message=return_val)

When running repokid display_role, I always get the following error message:

ubuntu@***************:/usr/local/src/repokid$ repokid display_role <account_id> <role_name>
Loaded config from /usr/local/src/repokid/config.json
Traceback (most recent call last):
  File "/usr/local/src/repokid/venv/bin/repokid", line 11, in <module>
    load_entry_point('repokid', 'console_scripts', 'repokid')()
  File "/usr/local/src/repokid/repokid/cli/repokid_cli.py", line 964, in main
    return display_role(account_number, role_name, dynamo_table, config, hooks)
  File "/usr/local/src/repokid/repokid/cli/repokid_cli.py", line 533, in display_role
    role_id = find_role_in_cache(dynamo_table, account_number, role_name)
  File "/usr/local/src/repokid/repokid/utils/dynamo.py", line 143, in find_role_in_cache
    ExpressionAttributeValues={':rn': role_name})
  File "/usr/local/src/repokid/venv/lib/python2.7/site-packages/boto3-1.4.4-py2.7.egg/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
  File "/usr/local/src/repokid/venv/lib/python2.7/site-packages/boto3-1.4.4-py2.7.egg/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/usr/local/src/repokid/venv/lib/python2.7/site-packages/botocore-1.5.92-py2.7.egg/botocore/client.py", line 310, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/src/repokid/venv/lib/python2.7/site-packages/botocore-1.5.92-py2.7.egg/botocore/client.py", line 599, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Query operation: The table does not have the specified index: RoleName

Unfortunately, I can't find the index RoleName in the documentation. Does the index still have to be added to the documentation?

@Mortinke
Copy link
Author

Mortinke commented Nov 23, 2017

With the commit e5cf04a the documentation is outdated.
Currently, the table should have the following properties:

  • RoleId (string) as a primary partition key, no primary sort key
  • A global secondary index named Account with
    • a primary partition key of Account
    • RoleId and Account as a projected attribute
  • A global secondary index named RoleName with
    • a primary partition key of RoleName
    • RoleId and RoleName as a projected attribute

@mcpeak
Copy link
Contributor

mcpeak commented Nov 25, 2017

Good call! Will update this later next week when I'm back from reinvent or accept a PR if you want to update it sooner. Thanks!

mcpeak pushed a commit that referenced this issue Dec 1, 2017
This commit updates the documentation to correctly reflect the
required tables and attributes.

fixes #58
@mcpeak mcpeak closed this as completed in #59 Dec 1, 2017
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 a pull request may close this issue.

2 participants