newrelic / newrelic-lambda-cli

A CLI to install the New Relic AWS Lambda integration and layers.
https://newrelic.com/products/serverless-aws-lambda
Apache License 2.0
47 stars 53 forks source link

`newrelic-lambda layers install` fails with an unexpected error #235

Open sinan-ku opened 1 year ago

sinan-ku commented 1 year ago

Description

newrelic-lambda layers install fails while I'm trying to install to one of my Lambda functions for the New Relic account: 3812596 Could you help me with that?

Relevant Logs / Console output

Here's the stacktrace:

Traceback (most recent call last):
  File "/opt/homebrew/bin/newrelic-lambda", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/newrelic_lambda_cli/cli/__init__.py", line 25, in main
    cli()
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/newrelic_lambda_cli/cli/layers.py", line 126, in install
    install_success = all(future.result() for future in as_completed(futures))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/newrelic_lambda_cli/cli/layers.py", line 126, in <genexpr>
    install_success = all(future.result() for future in as_completed(futures))
                          ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/newrelic_lambda_cli/utils.py", line 57, in _boto_error_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/newrelic_lambda_cli/layers.py", line 262, in install
    update_kwargs = _add_new_relic(input, config, nr_license_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/newrelic_lambda_cli/layers.py", line 86, in _add_new_relic
    runtime = config["Configuration"]["Runtime"]
              ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'Runtime'

Your Environment

❯ pip3 install newrelic-lambda-cli
Collecting newrelic-lambda-cli
  Downloading newrelic-lambda-cli-0.7.2.tar.gz (39 kB)

❯ python3 --version
Python 3.11.3
Shuvoid commented 11 months ago

I also faced the same bug

newrelic-lambda layers install \ --function arn:aws:lambda:ap-southeast-1:385375542684:function:dev_gkapp_backend \ --nr-account-id 4186549
Traceback (most recent call last): File "/opt/homebrew/bin/newrelic-lambda", line 8, in sys.exit(main()) File "/opt/homebrew/lib/python3.10/site-packages/newrelic_lambda_cli/cli/init.py", line 25, in main cli() File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(args, kwargs) File "/opt/homebrew/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), *args, *kwargs) File "/opt/homebrew/lib/python3.10/site-packages/newrelic_lambda_cli/cli/layers.py", line 126, in install install_success = all(future.result() for future in as_completed(futures)) File "/opt/homebrew/lib/python3.10/site-packages/newrelic_lambda_cli/cli/layers.py", line 126, in install_success = all(future.result() for future in as_completed(futures)) File "/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 451, in result return self.get_result() File "/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 403, in get_result raise self._exception File "/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) File "/opt/homebrew/lib/python3.10/site-packages/newrelic_lambda_cli/utils.py", line 65, in _boto_error_wrapper return func(*args, **kwargs) File "/opt/homebrew/lib/python3.10/site-packages/newrelic_lambda_cli/layers.py", line 262, in install update_kwargs = _add_new_relic(input, config, nr_license_key) File "/opt/homebrew/lib/python3.10/site-packages/newrelic_lambda_cli/layers.py", line 86, in _add_new_relic runtime = config["Configuration"]["Runtime"] KeyError: 'Runtime'

chaudharysaket commented 4 months ago

The AWS credentials, used to execute the commands, don't have necessary permissions, roles.