newrelic-lambda-cli 0.9.11__py2.py3-none-any.whl → 0.9.13__py2.py3-none-any.whl

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.
@@ -362,8 +362,6 @@ 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
366
  if __cached_license_key:
369
367
  return __cached_license_key
@@ -155,12 +155,6 @@ def register(group):
155
155
  @click.pass_context
156
156
  def install(ctx, **kwargs):
157
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
-
164
158
  input = LayerInstall(session=None, verbose=ctx.obj["VERBOSE"], **kwargs)
165
159
  input = input._replace(
166
160
  session=boto3.Session(
@@ -47,7 +47,18 @@ def index(region, runtime, architecture):
47
47
  ]
48
48
 
49
49
 
50
- def layer_selection(available_layers, runtime, architecture):
50
+ def layer_selection(
51
+ available_layers, runtime, architecture, upgrade=False, existing_layer_arn=None
52
+ ):
53
+ if upgrade and existing_layer_arn:
54
+ base_arn = existing_layer_arn.rsplit(":", 1)[0]
55
+
56
+ for i, layer in enumerate(available_layers):
57
+ candidate_arn = layer["LatestMatchingVersion"]["LayerVersionArn"]
58
+ candidate_base_arn = candidate_arn.rsplit(":", 1)[0]
59
+ if candidate_base_arn == base_arn:
60
+ return candidate_arn
61
+
51
62
  if len(available_layers) == 1:
52
63
  return available_layers[0]["LatestMatchingVersion"]["LayerVersionArn"]
53
64
 
@@ -147,8 +158,16 @@ def _add_new_relic(input, config, nr_license_key):
147
158
  % (config["Configuration"]["FunctionArn"], runtime, architecture)
148
159
  )
149
160
  return False
150
-
151
- new_relic_layer = layer_selection(available_layers, runtime, architecture)
161
+ existing_layer_arn = (
162
+ existing_newrelic_layer[0] if existing_newrelic_layer else None
163
+ )
164
+ new_relic_layer = layer_selection(
165
+ available_layers,
166
+ runtime,
167
+ architecture,
168
+ upgrade=input.upgrade,
169
+ existing_layer_arn=existing_layer_arn,
170
+ )
152
171
 
153
172
  update_kwargs = {
154
173
  "FunctionName": config["Configuration"]["FunctionArn"],
@@ -267,10 +286,10 @@ def _add_new_relic(input, config, nr_license_key):
267
286
  update_kwargs["Environment"]["Variables"][
268
287
  "NEW_RELIC_LICENSE_KEY"
269
288
  ] = nr_license_key
270
- else:
271
- update_kwargs["Environment"]["Variables"][
272
- "NEW_RELIC_LAMBDA_EXTENSION_ENABLED"
273
- ] = "false"
289
+ else:
290
+ update_kwargs["Environment"]["Variables"][
291
+ "NEW_RELIC_LAMBDA_EXTENSION_ENABLED"
292
+ ] = "false"
274
293
 
275
294
  if "dotnet" in runtime:
276
295
  update_kwargs["Environment"]["Variables"]["CORECLR_ENABLE_PROFILING"] = "1"
@@ -300,10 +319,6 @@ def install(input, function_arn):
300
319
  raise click.UsageError(
301
320
  "Please provide either the --nr-api-key or the --nr-ingest-key flag, but not both."
302
321
  )
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
- )
307
322
  assert isinstance(input, LayerInstall)
308
323
 
309
324
  client = input.session.client("lambda")
@@ -323,6 +338,7 @@ def install(input, function_arn):
323
338
  and nr_account_id
324
339
  and nr_account_id != str(input.nr_account_id)
325
340
  and not input.nr_api_key
341
+ and not input.nr_ingest_key
326
342
  ):
327
343
  raise click.UsageError(
328
344
  "A managed secret already exists in this region for New Relic account {0}. "
@@ -335,7 +351,12 @@ def install(input, function_arn):
335
351
  nr_account_id, input.nr_account_id, utils.NR_DOCS_ACT_LINKING_URL
336
352
  )
337
353
  )
338
- if input.enable_extension and not policy_arn and not input.nr_api_key:
354
+ if (
355
+ input.enable_extension
356
+ and not policy_arn
357
+ and not input.nr_api_key
358
+ and not input.nr_ingest_key
359
+ ):
339
360
  raise click.UsageError(
340
361
  "In order to use `--enable-extension`, you must first run "
341
362
  "`newrelic-lambda integrations install` with the "
@@ -347,7 +368,9 @@ def install(input, function_arn):
347
368
  )
348
369
 
349
370
  nr_license_key = None
350
- if (
371
+ if input.nr_ingest_key:
372
+ nr_license_key = input.nr_ingest_key
373
+ elif (
351
374
  not policy_arn
352
375
  or nr_account_id != str(input.nr_account_id)
353
376
  and input.nr_api_key
@@ -355,8 +378,6 @@ def install(input, function_arn):
355
378
  ):
356
379
  gql = api.validate_gql_credentials(input)
357
380
  nr_license_key = api.retrieve_license_key(gql)
358
- elif input.nr_ingest_key:
359
- nr_license_key = input.nr_ingest_key
360
381
 
361
382
  update_kwargs = _add_new_relic(input, config, nr_license_key)
362
383
  if isinstance(update_kwargs, bool):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: newrelic-lambda-cli
3
- Version: 0.9.11
3
+ Version: 0.9.13
4
4
  Summary: A CLI to install the New Relic AWS Lambda integration and layers.
5
5
  Home-page: https://github.com/newrelic/newrelic-lambda-cli
6
6
  Author: New Relic
@@ -1,9 +1,9 @@
1
1
  newrelic_lambda_cli/__init__.py,sha256=u4cy7hwbrNjK3xtldGQD_51aoNgSqGQ3IzFYsuvaIM4,149
2
- newrelic_lambda_cli/api.py,sha256=EwsuxIKHCjrB7knksn8Z4DRT-LLDFeUhMiA2R-7uNpI,15240
2
+ newrelic_lambda_cli/api.py,sha256=-lRsWBNO0YWV2yHp-zUbS2vs4AYJCn9yJngOrKAvmuo,15133
3
3
  newrelic_lambda_cli/cliutils.py,sha256=XDtvTlgbf2uVg01yCJrfJmmgxbF0nIL9x58ETyvefk8,685
4
4
  newrelic_lambda_cli/functions.py,sha256=p57ZUw424BaSUA_Gw8DrYsJOYKROEHEaXgARadqwcP0,2800
5
5
  newrelic_lambda_cli/integrations.py,sha256=r0gxfEqVHTGu3xbr4dOCDwm0-Yhoz3KntfeQRWvoWrQ,31266
6
- newrelic_lambda_cli/layers.py,sha256=kW5baQ71kd8nMu3nrHLzaI3xGsku1N5n2bl_oIP5Xe8,19760
6
+ newrelic_lambda_cli/layers.py,sha256=pyTbSCwJ2A3KP6YZiN-bkzt210UEj3j6dVnIFgijxWo,20339
7
7
  newrelic_lambda_cli/otel_ingestions.py,sha256=vi1Mlfc9nRvRWV7STwK7fDXZGozG8ufKohmpHcaWGic,9250
8
8
  newrelic_lambda_cli/permissions.py,sha256=H7v5IMpKaJIWC4Dff2YcTis4BKAAFIJr9IHWUj1LnF4,9093
9
9
  newrelic_lambda_cli/subscriptions.py,sha256=-BYkltqiDLdmhUB_Ot4w-5vvrKcQC6aHcTBLl1mlUlI,9564
@@ -13,15 +13,15 @@ newrelic_lambda_cli/cli/__init__.py,sha256=FciF2RVqQbpMKqEiN8qjO6qmdLB6Yv8LyyyPY
13
13
  newrelic_lambda_cli/cli/decorators.py,sha256=a3agkVfy8omkUSL4aKblwSX95xtxYOGASULDYcJDPHk,1786
14
14
  newrelic_lambda_cli/cli/functions.py,sha256=RSh2Cowe1_oQup8q5YRidp03z-BITo2uzvDh4zvLr4I,2601
15
15
  newrelic_lambda_cli/cli/integrations.py,sha256=aQAWcCCU2kBmbF8fLKwKB9bzSY0uipvnojajjTkhqEs,10461
16
- newrelic_lambda_cli/cli/layers.py,sha256=dMc_r42uz26Jf3ePC9r4MYIPb7B6MlS7zALtr5_b6IQ,7734
16
+ newrelic_lambda_cli/cli/layers.py,sha256=LM_vMHcfFAjSCtnaH34P0Jn1ixY07s93EzOBsEgRQK0,7584
17
17
  newrelic_lambda_cli/cli/otel_ingestions.py,sha256=4rTm9iYUo2qdMeqxJSrYLCA6ZXHy5bJnjDn9x54pCYc,6096
18
18
  newrelic_lambda_cli/cli/subscriptions.py,sha256=bUupv5iv3mUkC8t31nnI3BahoKxDnUJ8Rgq4QHJcFNU,5890
19
19
  newrelic_lambda_cli/templates/import-template.yaml,sha256=0r1yeoqpnqtEMggWomALkPG10NiANPWWBqz03rChch8,3771
20
20
  newrelic_lambda_cli/templates/license-key-secret.yaml,sha256=ZldQaLXsyF1K2I4X_AsLdH7kRmLkPUYI3talmhqQyHg,1849
21
21
  newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml,sha256=s7T73B_k-mAwgzJrD2xn8YGUNgn2E1V7Exifrl81ViU,2874
22
- newrelic_lambda_cli-0.9.11.dist-info/licenses/LICENSE,sha256=uuxDzQm0yfq_tNZX0tQYzsZUVRIF0jm3dBLZUojSYzI,11345
23
- newrelic_lambda_cli-0.9.11.dist-info/METADATA,sha256=kDErJ6n2tOKpwmeC7z-Kz-pCFXMlSglw8LibRZdW7_I,28715
24
- newrelic_lambda_cli-0.9.11.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
25
- newrelic_lambda_cli-0.9.11.dist-info/entry_points.txt,sha256=iks2k9Y4WNgIecsDzreIvMV9pGCjwwKTf33LKKvl2A8,65
26
- newrelic_lambda_cli-0.9.11.dist-info/top_level.txt,sha256=dxX2w58VgSUFiPD8C_lFuY-T2C1kjfeY0xi8iTh0r44,20
27
- newrelic_lambda_cli-0.9.11.dist-info/RECORD,,
22
+ newrelic_lambda_cli-0.9.13.dist-info/licenses/LICENSE,sha256=uuxDzQm0yfq_tNZX0tQYzsZUVRIF0jm3dBLZUojSYzI,11345
23
+ newrelic_lambda_cli-0.9.13.dist-info/METADATA,sha256=FgXCoP0n0coh0xQMDFh8h-QsY4ps6ZpjjfwGHDUsWTs,28715
24
+ newrelic_lambda_cli-0.9.13.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
25
+ newrelic_lambda_cli-0.9.13.dist-info/entry_points.txt,sha256=iks2k9Y4WNgIecsDzreIvMV9pGCjwwKTf33LKKvl2A8,65
26
+ newrelic_lambda_cli-0.9.13.dist-info/top_level.txt,sha256=dxX2w58VgSUFiPD8C_lFuY-T2C1kjfeY0xi8iTh0r44,20
27
+ newrelic_lambda_cli-0.9.13.dist-info/RECORD,,