Attempting to upgrade New Relic Lambda layers with the --upgrade flag using the --function installed filter results in an AttributeError. This occurs across different environments and Python versions, pointing to a possible bug in the newrelic-lambda-cli tool.
Expected Behavior
Running the command newrelic-lambda layers install --function installed --nr-account-id <account_id> --upgrade should upgrade the New Relic Lambda layers for all functions where the layer is already installed.
Current Behavior
The command execution ends with the error:
AttributeError: 'NoneType' object has no attribute 'client'
This occurs both on a local Mac environment and AWS CloudShell, but not when specifying a specific function by name.
Steps to Reproduce
Run newrelic-lambda layers install --function installed --nr-account-id <account_id> --upgrade on both a local Mac and within AWS CloudShell.
Error returned in both cases with AttributeError.
Environment
Local Environment:
Operating System: macOS Sonoma version 14.5
Python Version: 3.12 (the error also occurs with 3.9)
New Relic CLI Version: 0.9.1
CloudShell Environment:
Operating System: Amazon Linux 2023.4 (full PRETTY_NAME from /etc/os-release is "Amazon Linux 2023.4.20240401")
Python Version: 3.9
New Relic CLI Version: 0.9.1
Validating AWS Lambda functions are Installed
(.venv312)$ newrelic-lambda functions list
Function Name Runtime Installed
-------------------------------------- --------------- -----------
kmullaney-tf-demo-python python3.10 Yes
aws-controltower-NotificationForwarder python3.9 No
kmullaney-sam-esm-nodejs18x nodejs18.x Yes
Validating AWS Credentials and Permissions
Below are the results of executing AWS CLI commands to confirm that my AWS credentials are valid and the permissions for my assumed role are correct:
The above outputs confirm that my credentials are correctly configured, and I have the necessary permissions to list and potentially upgrade Lambda functions.
Logs
(.venv312)$ newrelic-lambda layers install --function installed --nr-account-id 1234567 --upgrade
Traceback (most recent call last):
File "/Users/kmullaney/.venv312/bin/newrelic-lambda", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/newrelic_lambda_cli/cli/__init__.py", line 26, in main
cli()
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/newrelic_lambda_cli/cli/layers.py", line 114, in install
functions = get_aliased_functions(input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/newrelic_lambda_cli/functions.py", line 82, in get_aliased_functions
for function in list_functions(input.session, alias):
File "/Users/kmullaney/.venv312/lib/python3.12/site-packages/newrelic_lambda_cli/functions.py", line 17, in list_functions
client = session.client("lambda")
^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'client'
Additional Context
The upgrade works as expected when specifying an individual function name instead of using the --function installed.
Possible Solution
(No suggestions, awaiting insights from newrelic-lambda-cli maintainers.)
Description
Attempting to upgrade New Relic Lambda layers with the
--upgrade
flag using the--function installed
filter results in anAttributeError
. This occurs across different environments and Python versions, pointing to a possible bug in thenewrelic-lambda-cli
tool.Expected Behavior
Running the command
newrelic-lambda layers install --function installed --nr-account-id <account_id> --upgrade
should upgrade the New Relic Lambda layers for all functions where the layer is already installed.Current Behavior
The command execution ends with the error:
This occurs both on a local Mac environment and AWS CloudShell, but not when specifying a specific function by name.
Steps to Reproduce
newrelic-lambda layers install --function installed --nr-account-id <account_id> --upgrade
on both a local Mac and within AWS CloudShell.AttributeError
.Environment
PRETTY_NAME
from/etc/os-release
is "Amazon Linux 2023.4.20240401")Validating AWS Lambda functions are
Installed
Validating AWS Credentials and Permissions
Below are the results of executing AWS CLI commands to confirm that my AWS credentials are valid and the permissions for my assumed role are correct:
aws sts get-caller-identity
:aws lambda list-functions
:aws iam list-attached-role-policies --role-name AWSReservedSSO_1234567
:The above outputs confirm that my credentials are correctly configured, and I have the necessary permissions to list and potentially upgrade Lambda functions.
Logs
Additional Context
The upgrade works as expected when specifying an individual function name instead of using the
--function installed
.Possible Solution
(No suggestions, awaiting insights from
newrelic-lambda-cli
maintainers.)