newrelic-lambda-cli 0.9.10__tar.gz → 0.9.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/PKG-INFO +1 -1
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/api.py +3 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/layers.py +13 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/layers.py +20 -5
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/types.py +1 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/PKG-INFO +1 -1
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/setup.py +1 -1
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_layers.py +288 -6
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/CODE_OF_CONDUCT.md +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/CONTRIBUTING.md +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/LICENSE +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/MANIFEST.in +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/README.md +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/THIRD_PARTY_NOTICES.md +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/__init__.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/__init__.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/decorators.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/functions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/integrations.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/otel_ingestions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/subscriptions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cliutils.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/functions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/integrations.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/otel_ingestions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/permissions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/subscriptions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/templates/import-template.yaml +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/templates/license-key-secret.yaml +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/utils.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/SOURCES.txt +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/dependency_links.txt +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/entry_points.txt +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/not-zip-safe +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/requires.txt +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/top_level.txt +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/pyproject.toml +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/setup.cfg +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_api.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_functions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_integrations.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_new_relic_gql.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_permissions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_subscriptions.py +0 -0
- {newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/tests/test_utils.py +0 -0
|
@@ -362,6 +362,9 @@ def validate_gql_credentials(input):
|
|
|
362
362
|
|
|
363
363
|
def retrieve_license_key(gql):
|
|
364
364
|
global __cached_license_key
|
|
365
|
+
if gql is None and input and getattr(input, "nr_ingest_key", None):
|
|
366
|
+
return input.nr_ingest_key
|
|
367
|
+
|
|
365
368
|
if __cached_license_key:
|
|
366
369
|
return __cached_license_key
|
|
367
370
|
assert isinstance(gql, NewRelicGQL)
|
|
@@ -42,6 +42,13 @@ def register(group):
|
|
|
42
42
|
metavar="<key>",
|
|
43
43
|
required=False,
|
|
44
44
|
)
|
|
45
|
+
@click.option(
|
|
46
|
+
"--nr-ingest-key",
|
|
47
|
+
envvar="NEW_RELIC_INGEST_KEY",
|
|
48
|
+
help="New Relic License/Ingest Key (alternative to --nr-api-key)",
|
|
49
|
+
metavar="<key>",
|
|
50
|
+
required=False,
|
|
51
|
+
)
|
|
45
52
|
@click.option(
|
|
46
53
|
"--nr-region",
|
|
47
54
|
default="us",
|
|
@@ -148,6 +155,12 @@ def register(group):
|
|
|
148
155
|
@click.pass_context
|
|
149
156
|
def install(ctx, **kwargs):
|
|
150
157
|
"""Install New Relic AWS Lambda Layers"""
|
|
158
|
+
|
|
159
|
+
if "nr_ingest_key" not in kwargs:
|
|
160
|
+
kwargs["nr_ingest_key"] = None
|
|
161
|
+
if "nr_api_key" not in kwargs:
|
|
162
|
+
kwargs["nr_api_key"] = None
|
|
163
|
+
|
|
151
164
|
input = LayerInstall(session=None, verbose=ctx.obj["VERBOSE"], **kwargs)
|
|
152
165
|
input = input._replace(
|
|
153
166
|
session=boto3.Session(
|
|
@@ -258,14 +258,19 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
258
258
|
"NEW_RELIC_LOG_ENDPOINT"
|
|
259
259
|
] = "https://staging-log-api.newrelic.com/log/v1"
|
|
260
260
|
|
|
261
|
-
if
|
|
261
|
+
if input.nr_ingest_key:
|
|
262
|
+
update_kwargs["Environment"]["Variables"][
|
|
263
|
+
"NEW_RELIC_LICENSE_KEY"
|
|
264
|
+
] = input.nr_ingest_key
|
|
265
|
+
success("Using New Relic ingest key for layer configuration")
|
|
266
|
+
elif nr_license_key:
|
|
262
267
|
update_kwargs["Environment"]["Variables"][
|
|
263
268
|
"NEW_RELIC_LICENSE_KEY"
|
|
264
269
|
] = nr_license_key
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
else:
|
|
271
|
+
update_kwargs["Environment"]["Variables"][
|
|
272
|
+
"NEW_RELIC_LAMBDA_EXTENSION_ENABLED"
|
|
273
|
+
] = "false"
|
|
269
274
|
|
|
270
275
|
if "dotnet" in runtime:
|
|
271
276
|
update_kwargs["Environment"]["Variables"]["CORECLR_ENABLE_PROFILING"] = "1"
|
|
@@ -291,6 +296,14 @@ def _add_new_relic(input, config, nr_license_key):
|
|
|
291
296
|
|
|
292
297
|
@catch_boto_errors
|
|
293
298
|
def install(input, function_arn):
|
|
299
|
+
if input.nr_api_key and input.nr_ingest_key:
|
|
300
|
+
raise click.UsageError(
|
|
301
|
+
"Please provide either the --nr-api-key or the --nr-ingest-key flag, but not both."
|
|
302
|
+
)
|
|
303
|
+
if not input.nr_api_key and not input.nr_ingest_key:
|
|
304
|
+
raise click.UsageError(
|
|
305
|
+
"Please provide either the --nr-api-key or the --nr-ingest-key flag."
|
|
306
|
+
)
|
|
294
307
|
assert isinstance(input, LayerInstall)
|
|
295
308
|
|
|
296
309
|
client = input.session.client("lambda")
|
|
@@ -342,6 +355,8 @@ def install(input, function_arn):
|
|
|
342
355
|
):
|
|
343
356
|
gql = api.validate_gql_credentials(input)
|
|
344
357
|
nr_license_key = api.retrieve_license_key(gql)
|
|
358
|
+
elif input.nr_ingest_key:
|
|
359
|
+
nr_license_key = input.nr_ingest_key
|
|
345
360
|
|
|
346
361
|
update_kwargs = _add_new_relic(input, config, nr_license_key)
|
|
347
362
|
if isinstance(update_kwargs, bool):
|
|
@@ -6,7 +6,7 @@ README = open(os.path.join(os.path.dirname(__file__), "README.md"), "r").read()
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="newrelic-lambda-cli",
|
|
9
|
-
version="0.9.
|
|
9
|
+
version="0.9.11",
|
|
10
10
|
python_requires=">=3.3",
|
|
11
11
|
description="A CLI to install the New Relic AWS Lambda integration and layers.",
|
|
12
12
|
long_description=README,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import boto3
|
|
2
|
+
import click
|
|
2
3
|
from click import UsageError
|
|
3
4
|
from moto import mock_aws
|
|
4
5
|
import pytest
|
|
@@ -49,7 +50,7 @@ def test_add_new_relic(aws_credentials, mock_function_config):
|
|
|
49
50
|
)
|
|
50
51
|
assert (
|
|
51
52
|
update_kwargs["Environment"]["Variables"]["NEW_RELIC_LAMBDA_EXTENSION_ENABLED"]
|
|
52
|
-
== "
|
|
53
|
+
== "false"
|
|
53
54
|
)
|
|
54
55
|
assert (
|
|
55
56
|
update_kwargs["Environment"]["Variables"][
|
|
@@ -316,7 +317,6 @@ def test_install_apm(aws_credentials, mock_function_config):
|
|
|
316
317
|
"EXISTING_ENV_VAR": "Hello World",
|
|
317
318
|
"NEW_RELIC_ACCOUNT_ID": "12345",
|
|
318
319
|
"NEW_RELIC_LAMBDA_HANDLER": "original_handler",
|
|
319
|
-
"NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "false",
|
|
320
320
|
"NEW_RELIC_APM_LAMBDA_MODE": "True",
|
|
321
321
|
}
|
|
322
322
|
},
|
|
@@ -378,7 +378,7 @@ def test_add_new_relic_dotnet(aws_credentials, mock_function_config):
|
|
|
378
378
|
update_kwargs["Environment"]["Variables"][
|
|
379
379
|
"NEW_RELIC_LAMBDA_EXTENSION_ENABLED"
|
|
380
380
|
]
|
|
381
|
-
== "
|
|
381
|
+
== "false"
|
|
382
382
|
)
|
|
383
383
|
assert (
|
|
384
384
|
update_kwargs["Environment"]["Variables"][
|
|
@@ -621,7 +621,13 @@ def test_install_failure(aws_credentials, mock_function_config):
|
|
|
621
621
|
mock_client.get_function.return_value = config
|
|
622
622
|
with pytest.raises(UsageError):
|
|
623
623
|
install(
|
|
624
|
-
layer_install(
|
|
624
|
+
layer_install(
|
|
625
|
+
nr_account_id=9876543,
|
|
626
|
+
session=mock_session,
|
|
627
|
+
nr_api_key=None,
|
|
628
|
+
nr_ingest_key=None,
|
|
629
|
+
),
|
|
630
|
+
"foobarbaz",
|
|
625
631
|
)
|
|
626
632
|
|
|
627
633
|
|
|
@@ -639,7 +645,13 @@ def test_install(aws_credentials, mock_function_config):
|
|
|
639
645
|
mock_client.get_function.return_value = config
|
|
640
646
|
with pytest.raises(UsageError):
|
|
641
647
|
install(
|
|
642
|
-
layer_install(
|
|
648
|
+
layer_install(
|
|
649
|
+
nr_account_id=9876543,
|
|
650
|
+
session=mock_session,
|
|
651
|
+
nr_api_key=None,
|
|
652
|
+
nr_ingest_key=None,
|
|
653
|
+
),
|
|
654
|
+
"foobarbaz",
|
|
643
655
|
)
|
|
644
656
|
|
|
645
657
|
mock_client = mock_session.client.return_value
|
|
@@ -681,7 +693,6 @@ def test_install(aws_credentials, mock_function_config):
|
|
|
681
693
|
"EXISTING_ENV_VAR": "Hello World",
|
|
682
694
|
"NEW_RELIC_ACCOUNT_ID": "12345",
|
|
683
695
|
"NEW_RELIC_LAMBDA_HANDLER": "original_handler",
|
|
684
|
-
"NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "false",
|
|
685
696
|
}
|
|
686
697
|
},
|
|
687
698
|
Layers=ANY,
|
|
@@ -1150,3 +1161,274 @@ def test_add_new_relic_sets_both_nr_tags_and_env_delimiter(
|
|
|
1150
1161
|
assert (
|
|
1151
1162
|
update_kwargs["Environment"]["Variables"]["NR_ENV_DELIMITER"] == delimiter_value
|
|
1152
1163
|
)
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
@mock_aws
|
|
1167
|
+
def test_add_new_relic_with_ingest_key(aws_credentials, mock_function_config):
|
|
1168
|
+
"""Test _add_new_relic function with ingest key instead of API key"""
|
|
1169
|
+
session = boto3.Session(region_name="us-east-1")
|
|
1170
|
+
|
|
1171
|
+
config = mock_function_config("python3.12")
|
|
1172
|
+
|
|
1173
|
+
update_kwargs = _add_new_relic(
|
|
1174
|
+
layer_install(
|
|
1175
|
+
session=session,
|
|
1176
|
+
aws_region="us-east-1",
|
|
1177
|
+
nr_account_id=12345,
|
|
1178
|
+
enable_extension=True,
|
|
1179
|
+
nr_ingest_key="test-ingest-key-12345",
|
|
1180
|
+
),
|
|
1181
|
+
config,
|
|
1182
|
+
nr_license_key=None,
|
|
1183
|
+
)
|
|
1184
|
+
|
|
1185
|
+
# Verify ingest key is used for NEW_RELIC_LICENSE_KEY
|
|
1186
|
+
assert (
|
|
1187
|
+
update_kwargs["Environment"]["Variables"]["NEW_RELIC_LICENSE_KEY"]
|
|
1188
|
+
== "test-ingest-key-12345"
|
|
1189
|
+
)
|
|
1190
|
+
assert (
|
|
1191
|
+
update_kwargs["Environment"]["Variables"]["NEW_RELIC_LAMBDA_EXTENSION_ENABLED"]
|
|
1192
|
+
== "true"
|
|
1193
|
+
)
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
@mock_aws
|
|
1197
|
+
def test_add_new_relic_without_license_key_or_ingest_key(
|
|
1198
|
+
aws_credentials, mock_function_config
|
|
1199
|
+
):
|
|
1200
|
+
"""Test _add_new_relic function when neither license key nor ingest key is provided"""
|
|
1201
|
+
session = boto3.Session(region_name="us-east-1")
|
|
1202
|
+
|
|
1203
|
+
config = mock_function_config("python3.12")
|
|
1204
|
+
|
|
1205
|
+
update_kwargs = _add_new_relic(
|
|
1206
|
+
layer_install(
|
|
1207
|
+
session=session,
|
|
1208
|
+
aws_region="us-east-1",
|
|
1209
|
+
nr_account_id=12345,
|
|
1210
|
+
enable_extension=True,
|
|
1211
|
+
),
|
|
1212
|
+
config,
|
|
1213
|
+
nr_license_key=None,
|
|
1214
|
+
)
|
|
1215
|
+
|
|
1216
|
+
# When no license key or ingest key is provided, extension should be disabled
|
|
1217
|
+
assert (
|
|
1218
|
+
update_kwargs["Environment"]["Variables"]["NEW_RELIC_LAMBDA_EXTENSION_ENABLED"]
|
|
1219
|
+
== "false"
|
|
1220
|
+
)
|
|
1221
|
+
assert "NEW_RELIC_LICENSE_KEY" not in update_kwargs["Environment"]["Variables"]
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
@mock_aws
|
|
1225
|
+
def test_add_new_relic_staging_region(aws_credentials, mock_function_config):
|
|
1226
|
+
"""Test _add_new_relic function with staging region"""
|
|
1227
|
+
session = boto3.Session(region_name="us-east-1")
|
|
1228
|
+
|
|
1229
|
+
config = mock_function_config("python3.12")
|
|
1230
|
+
|
|
1231
|
+
update_kwargs = _add_new_relic(
|
|
1232
|
+
layer_install(
|
|
1233
|
+
session=session,
|
|
1234
|
+
aws_region="us-east-1",
|
|
1235
|
+
nr_account_id=12345,
|
|
1236
|
+
enable_extension=True,
|
|
1237
|
+
nr_region="staging",
|
|
1238
|
+
nr_ingest_key="test-ingest-key",
|
|
1239
|
+
),
|
|
1240
|
+
config,
|
|
1241
|
+
nr_license_key=None,
|
|
1242
|
+
)
|
|
1243
|
+
|
|
1244
|
+
# Verify staging endpoints are set
|
|
1245
|
+
assert (
|
|
1246
|
+
update_kwargs["Environment"]["Variables"]["NEW_RELIC_TELEMETRY_ENDPOINT"]
|
|
1247
|
+
== "https://staging-cloud-collector.newrelic.com/aws/lambda/v1"
|
|
1248
|
+
)
|
|
1249
|
+
assert (
|
|
1250
|
+
update_kwargs["Environment"]["Variables"]["NEW_RELIC_LOG_ENDPOINT"]
|
|
1251
|
+
== "https://staging-log-api.newrelic.com/log/v1"
|
|
1252
|
+
)
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
def test_install_with_both_api_key_and_ingest_key(
|
|
1256
|
+
aws_credentials, mock_function_config
|
|
1257
|
+
):
|
|
1258
|
+
"""Test install function fails when both API key and ingest key are provided"""
|
|
1259
|
+
mock_session = MagicMock()
|
|
1260
|
+
mock_session.region_name = "us-east-1"
|
|
1261
|
+
|
|
1262
|
+
with pytest.raises(
|
|
1263
|
+
UsageError,
|
|
1264
|
+
match="Please provide either the --nr-api-key or the --nr-ingest-key flag, but not both",
|
|
1265
|
+
):
|
|
1266
|
+
install(
|
|
1267
|
+
layer_install(
|
|
1268
|
+
session=mock_session,
|
|
1269
|
+
nr_account_id=12345,
|
|
1270
|
+
nr_api_key="test-api-key",
|
|
1271
|
+
nr_ingest_key="test-ingest-key",
|
|
1272
|
+
),
|
|
1273
|
+
"test-function",
|
|
1274
|
+
)
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
def test_install_with_ingest_key_success(aws_credentials, mock_function_config):
|
|
1278
|
+
"""Test successful install with ingest key"""
|
|
1279
|
+
mock_session = MagicMock()
|
|
1280
|
+
mock_session.region_name = "us-east-1"
|
|
1281
|
+
mock_client = mock_session.client.return_value
|
|
1282
|
+
|
|
1283
|
+
with patch(
|
|
1284
|
+
"newrelic_lambda_cli.layers._get_license_key_outputs"
|
|
1285
|
+
) as mock_get_license_key_outputs, patch(
|
|
1286
|
+
"newrelic_lambda_cli.layers.get_function"
|
|
1287
|
+
) as mock_get_function, patch(
|
|
1288
|
+
"newrelic_lambda_cli.layers._add_new_relic"
|
|
1289
|
+
) as mock_add_new_relic:
|
|
1290
|
+
|
|
1291
|
+
# Set up policy_arn so GraphQL validation is skipped
|
|
1292
|
+
mock_get_license_key_outputs.return_value = (None, "12345", "test-policy-arn")
|
|
1293
|
+
mock_get_function.return_value = mock_function_config("python3.12")
|
|
1294
|
+
mock_add_new_relic.return_value = {
|
|
1295
|
+
"FunctionName": "test-function",
|
|
1296
|
+
"Environment": {"Variables": {"NEW_RELIC_LICENSE_KEY": "test-ingest-key"}},
|
|
1297
|
+
"Layers": ["test-layer"],
|
|
1298
|
+
}
|
|
1299
|
+
mock_client.update_function_configuration.return_value = {
|
|
1300
|
+
"Configuration": {
|
|
1301
|
+
"Layers": [{"Arn": "existing-layer"}],
|
|
1302
|
+
"FunctionArn": "test-function",
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
result = install(
|
|
1307
|
+
layer_install(
|
|
1308
|
+
session=mock_session,
|
|
1309
|
+
nr_account_id=12345,
|
|
1310
|
+
nr_ingest_key="test-ingest-key",
|
|
1311
|
+
enable_extension=False,
|
|
1312
|
+
),
|
|
1313
|
+
"test-function",
|
|
1314
|
+
)
|
|
1315
|
+
|
|
1316
|
+
assert result is True
|
|
1317
|
+
mock_client.update_function_configuration.assert_called_once()
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
@mock_aws
|
|
1321
|
+
def test_install_with_apm_and_verbose(aws_credentials, mock_function_config):
|
|
1322
|
+
"""Test install with APM enabled and verbose output to cover success message paths"""
|
|
1323
|
+
mock_session = MagicMock()
|
|
1324
|
+
mock_session.region_name = "us-east-1"
|
|
1325
|
+
mock_client = mock_session.client.return_value
|
|
1326
|
+
|
|
1327
|
+
with patch(
|
|
1328
|
+
"newrelic_lambda_cli.layers._get_license_key_outputs"
|
|
1329
|
+
) as mock_get_license_key_outputs, patch(
|
|
1330
|
+
"newrelic_lambda_cli.layers.get_function"
|
|
1331
|
+
) as mock_get_function, patch(
|
|
1332
|
+
"newrelic_lambda_cli.layers._add_new_relic"
|
|
1333
|
+
) as mock_add_new_relic:
|
|
1334
|
+
|
|
1335
|
+
mock_get_license_key_outputs.return_value = (None, "12345", "test-policy-arn")
|
|
1336
|
+
mock_get_function.return_value = mock_function_config("python3.12")
|
|
1337
|
+
mock_add_new_relic.return_value = {
|
|
1338
|
+
"FunctionName": "test-function",
|
|
1339
|
+
"Environment": {"Variables": {"NEW_RELIC_LICENSE_KEY": "test-key"}},
|
|
1340
|
+
"Layers": ["test-layer"],
|
|
1341
|
+
}
|
|
1342
|
+
mock_client.update_function_configuration.return_value = {
|
|
1343
|
+
"Configuration": {"Layers": [], "FunctionArn": "test-function"}
|
|
1344
|
+
}
|
|
1345
|
+
mock_client.tag_resource.return_value = {}
|
|
1346
|
+
|
|
1347
|
+
result = install(
|
|
1348
|
+
layer_install(
|
|
1349
|
+
session=mock_session,
|
|
1350
|
+
nr_account_id=12345,
|
|
1351
|
+
nr_api_key="test-api-key",
|
|
1352
|
+
nr_region="us",
|
|
1353
|
+
apm=True,
|
|
1354
|
+
verbose=True,
|
|
1355
|
+
enable_extension=False,
|
|
1356
|
+
),
|
|
1357
|
+
"test-function",
|
|
1358
|
+
)
|
|
1359
|
+
|
|
1360
|
+
assert result is True
|
|
1361
|
+
mock_client.tag_resource.assert_called_once()
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
@mock_aws
|
|
1365
|
+
def test_install_function_not_found(aws_credentials):
|
|
1366
|
+
"""Test install function when function is not found"""
|
|
1367
|
+
mock_session = MagicMock()
|
|
1368
|
+
mock_session.region_name = "us-east-1"
|
|
1369
|
+
|
|
1370
|
+
with patch("newrelic_lambda_cli.layers.get_function") as mock_get_function:
|
|
1371
|
+
mock_get_function.return_value = None
|
|
1372
|
+
|
|
1373
|
+
result = install(
|
|
1374
|
+
layer_install(
|
|
1375
|
+
session=mock_session,
|
|
1376
|
+
nr_account_id=12345,
|
|
1377
|
+
nr_api_key="test-api-key",
|
|
1378
|
+
),
|
|
1379
|
+
"nonexistent-function",
|
|
1380
|
+
)
|
|
1381
|
+
|
|
1382
|
+
assert result is False
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
def test_install_secret_account_mismatch(aws_credentials):
|
|
1386
|
+
"""Test install with managed secret account ID mismatch"""
|
|
1387
|
+
mock_session = MagicMock()
|
|
1388
|
+
mock_session.region_name = "us-east-1"
|
|
1389
|
+
|
|
1390
|
+
with patch(
|
|
1391
|
+
"newrelic_lambda_cli.layers._get_license_key_outputs"
|
|
1392
|
+
) as mock_get_license_key_outputs, patch(
|
|
1393
|
+
"newrelic_lambda_cli.layers.get_function"
|
|
1394
|
+
) as mock_get_function:
|
|
1395
|
+
|
|
1396
|
+
# Different account ID in existing secret
|
|
1397
|
+
mock_get_license_key_outputs.return_value = (None, "99999", "test-policy-arn")
|
|
1398
|
+
mock_get_function.return_value = {"Configuration": {"FunctionArn": "test"}}
|
|
1399
|
+
|
|
1400
|
+
with pytest.raises(UsageError, match="A managed secret already exists"):
|
|
1401
|
+
install(
|
|
1402
|
+
layer_install(
|
|
1403
|
+
session=mock_session,
|
|
1404
|
+
nr_account_id=12345, # Different from secret account ID
|
|
1405
|
+
nr_ingest_key="test-ingest-key",
|
|
1406
|
+
),
|
|
1407
|
+
"test-function",
|
|
1408
|
+
)
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
def test_install_extension_without_secret_or_api_key(aws_credentials):
|
|
1412
|
+
"""Test install with extension enabled but no secret or API key"""
|
|
1413
|
+
mock_session = MagicMock()
|
|
1414
|
+
mock_session.region_name = "us-east-1"
|
|
1415
|
+
|
|
1416
|
+
with patch(
|
|
1417
|
+
"newrelic_lambda_cli.layers._get_license_key_outputs"
|
|
1418
|
+
) as mock_get_license_key_outputs, patch(
|
|
1419
|
+
"newrelic_lambda_cli.layers.get_function"
|
|
1420
|
+
) as mock_get_function:
|
|
1421
|
+
|
|
1422
|
+
mock_get_license_key_outputs.return_value = (None, None, None) # No secret
|
|
1423
|
+
mock_get_function.return_value = {"Configuration": {"FunctionArn": "test"}}
|
|
1424
|
+
|
|
1425
|
+
with pytest.raises(UsageError, match="In order to use `--enable-extension`"):
|
|
1426
|
+
install(
|
|
1427
|
+
layer_install(
|
|
1428
|
+
session=mock_session,
|
|
1429
|
+
nr_account_id=12345,
|
|
1430
|
+
enable_extension=True,
|
|
1431
|
+
nr_ingest_key="test-ingest-key",
|
|
1432
|
+
),
|
|
1433
|
+
"test-function",
|
|
1434
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/__init__.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/decorators.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/functions.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/integrations.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/otel_ingestions.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/cli/subscriptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/integrations.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/otel_ingestions.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/permissions.py
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli/subscriptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/requires.txt
RENAMED
|
File without changes
|
{newrelic_lambda_cli-0.9.10 → newrelic_lambda_cli-0.9.11}/newrelic_lambda_cli.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|