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

Loki authentication for deployed lambda functions #3

Open
mihai-dobre opened this issue Jun 7, 2020 · 2 comments
Open

Loki authentication for deployed lambda functions #3

mihai-dobre opened this issue Jun 7, 2020 · 2 comments

Comments

@mihai-dobre
Copy link

I've deployed a lambda function using the loki-shipper.py. It has LOKI_ENDPOINT as environment variable but it doesn't have any authentication. Loki requires authentication in order to be able to push logs to the endpoint(I'm using grafana cloud and I've configured a loki endpoint on the grafana logs dashboard).

I've made all the changes and updated the docs(Readme.md) . Please check the blow archive as I wasn't able to raise a PR with the changes.
loki-shipper-auth-readme.zip

@asanz-mrmilu
Copy link

It fails when executing the command "shipper" with auth:

Traceback (most recent call last):
  File "demo/cli.py", line 300, in <module>
    cli()
  File "/home/adsanz/Downloads/loki-shipper/venv/lib/python3.8/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/adsanz/Downloads/loki-shipper/venv/lib/python3.8/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/adsanz/Downloads/loki-shipper/venv/lib/python3.8/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/adsanz/Downloads/loki-shipper/venv/lib/python3.8/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/adsanz/Downloads/loki-shipper/venv/lib/python3.8/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/adsanz/Downloads/loki-shipper/venv/lib/python3.8/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
TypeError: shipper() got an unexpected keyword argument 'user'


@asanz-mrmilu
Copy link

For this to work "loki_user" and "loki_password" should be renamed to "user" and "password" since that's the name they get from click.options() @mihai-dobre

@cli.command(short_help="Deploy Loki shipper lambda function.")
@click.option('-l', '--loki', default='http://localhost:3100', help='Loki endpoint URL')
@click.option('-U', '--user', default='', help='User for Loki authentication')
@click.option('-W', '--password', default='', help='Password for Loki authentication')
@click.option('-b', '--build', default=False, is_flag=True, help='Flag indicates if deployment packages should be build')
@click.argument('action', nargs=1, type=click.Choice(['start', 'stop']))
@click.pass_context
def shipper(context, loki, action, build, user='', password=''):
    """        Starts/Stops the shipper lambda function    """
    if build or __should_package():
        context.invoke(package)
    config = {
        'FunctionName': SHIPPER_NAME,
        'Runtime': 'python3.7',
        'Role': '',  # Injected on deployment
        'Handler': 'loki-shipper.lambda_handler',
        'Code': {'ZipFile': open(SHIPPER_ZIP, 'rb').read()},
        'Description': 'Loki Shipper',
        'Environment': {
            'Variables': {
                'LOKI_ENDPOINT': loki,
                'LOKI_USER': user,
                'LOKI_PASSWORD': password
            }
        }
    }
    __start_lambda(config) if action == 'start' else __stop_lambda(config)

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

No branches or pull requests

2 participants