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 EC2 Auth:NameError: name 'load_vault_token' is not defined #333

Open
kawsark opened this issue Nov 5, 2018 · 1 comment
Open

AWS EC2 Auth:NameError: name 'load_vault_token' is not defined #333

kawsark opened this issue Nov 5, 2018 · 1 comment
Labels
CI/CD related to CI/CD (not necessarily tests) documentation documentation updates and/or requests for expanded documentation

Comments

@kawsark
Copy link

kawsark commented Nov 5, 2018

For the AWS EC2 Authentication Method I get the following error:

Traceback (most recent call last):
  File "hvactest.py", line 145, in <module>
    authenticated_vault_client = get_vault_client(verify_certs=False, ec2_role="dev-role")
  File "hvactest.py", line 137, in get_vault_client
    vault_client.token = load_vault_token(vault_client, ec2_role=ec2_role)
NameError: name 'load_vault_token' is not defined

This is expected because load_vault_token is not defined:

vault_client.token = load_vault_token(vault_client, ec2_role=ec2_role)
@jeffwecan jeffwecan added question Questions requesting clarification or guidance on hvac usage documentation documentation updates and/or requests for expanded documentation labels Nov 5, 2018
@jeffwecan
Copy link
Member

For what it is worth, this is the implementation for the aforementioned undefined method that was related to the documented example code:

def load_vault_token(vault_client, ec2_role=None):
    """
    Retrieves a vault token, first from a "VAULT_TOKEN" env var if available. If this env var is unavailable, we use a
    Vault authentication backend to retrieve a token (currently limited to AWS EC2 authentication)
    :param vault_client: hvac.Client
    :param ec2_role: str, Name of the Vault AWS auth backend role to use when retrieving a token (if applicable)
    :return: string, a vault token
    """
    vault_token = os.environ.get('VAULT_TOKEN')
    if vault_token is None and ec2_role is not None:
        auth_ec2_resp = auth_ec2(
            vault_client=vault_client,
            role=ec2_role,
        )
        logger.debug('auth_ec2_resp:\n{}'.format(auth_ec2_resp))
        vault_token = auth_ec2_resp['auth']['client_token']
    return vault_token

(Note: this specific implementation obviously is keyed on the AWS EC2 auth method as its default source for a Vault token.)

That said, I figure this card could cover two potential issues:

  • Truing up the example documentation so that it can be executed without too much additional intervention
  • Updating hvac's documentation CI/CD pipeline to include the testing of documentation

With that said, apologies for the delay in responding to this issue and we'll try to implement resolution to the two action items raised as soon as possible!

@jeffwecan jeffwecan added CI/CD related to CI/CD (not necessarily tests) and removed question Questions requesting clarification or guidance on hvac usage labels Jan 18, 2019
@jeffwecan jeffwecan added this to Needs triage in Bug / Feature Request Triage via automation Jan 18, 2019
@jeffwecan jeffwecan added this to the 0.7.after3 milestone Jan 18, 2019
@jeffwecan jeffwecan moved this from Needs triage to Medium Priority in Bug / Feature Request Triage Jan 18, 2019
@jeffwecan jeffwecan modified the milestones: 0.8.3, 0.8.4 May 18, 2019
@jeffwecan jeffwecan modified the milestones: 0.9.1, 0.9.2 May 25, 2019
@jeffwecan jeffwecan removed this from the 0.9.2 milestone Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD related to CI/CD (not necessarily tests) documentation documentation updates and/or requests for expanded documentation
Projects
Bug / Feature Request Triage
  
Medium Priority
Development

No branches or pull requests

2 participants