newrelic-lambda-cli 0.8.0__py2.py3-none-any.whl → 0.9.1__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.
@@ -6,6 +6,7 @@ from newrelic_lambda_cli.cli import functions, integrations, layers, subscriptio
6
6
 
7
7
 
8
8
  @click.group()
9
+ @click.version_option()
9
10
  @click.option("--verbose", "-v", help="Increase verbosity", is_flag=True)
10
11
  @click.pass_context
11
12
  def cli(ctx, verbose):
@@ -39,6 +39,14 @@ def register(group):
39
39
  help="Determines if logs are forwarded to New Relic Logging",
40
40
  is_flag=True,
41
41
  )
42
+ @click.option(
43
+ "--stackname",
44
+ default="NewRelicLogIngestion",
45
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
46
+ metavar="<arn>",
47
+ show_default=False,
48
+ required=False,
49
+ )
42
50
  @click.option(
43
51
  "--memory-size",
44
52
  "-m",
@@ -195,6 +203,14 @@ def install(ctx, **kwargs):
195
203
  required=False,
196
204
  type=click.INT,
197
205
  )
206
+ @click.option(
207
+ "--stackname",
208
+ default="NewRelicLogIngestion",
209
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
210
+ metavar="<arn>",
211
+ show_default=False,
212
+ required=False,
213
+ )
198
214
  @click.option("--force", "-f", help="Force uninstall non-interactively", is_flag=True)
199
215
  def uninstall(**kwargs):
200
216
  """Uninstall New Relic AWS Lambda Integration"""
@@ -250,6 +266,14 @@ def uninstall(**kwargs):
250
266
  default=None,
251
267
  help="Determines if logs are forwarded to New Relic Logging",
252
268
  )
269
+ @click.option(
270
+ "--stackname",
271
+ default="NewRelicLogIngestion",
272
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
273
+ metavar="<arn>",
274
+ show_default=False,
275
+ required=False,
276
+ )
253
277
  @click.option(
254
278
  "--memory-size",
255
279
  "-m",
@@ -272,6 +296,14 @@ def uninstall(**kwargs):
272
296
  metavar="<role_name>",
273
297
  show_default=False,
274
298
  )
299
+ @click.option(
300
+ "--stackname",
301
+ default="NewRelicLogIngestion",
302
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
303
+ metavar="<arn>",
304
+ show_default=False,
305
+ required=False,
306
+ )
275
307
  @click.option(
276
308
  "--enable-license-key-secret/--disable-license-key-secret",
277
309
  default=True,
@@ -108,12 +108,6 @@ def install(ctx, **kwargs):
108
108
  """Install New Relic AWS Lambda Layers"""
109
109
  input = LayerInstall(session=None, verbose=ctx.obj["VERBOSE"], **kwargs)
110
110
 
111
- input = input._replace(
112
- session=boto3.Session(
113
- profile_name=input.aws_profile, region_name=input.aws_region
114
- )
115
- )
116
-
117
111
  if input.aws_permissions_check:
118
112
  permissions.ensure_layer_install_permissions(input)
119
113
 
@@ -121,7 +115,16 @@ def install(ctx, **kwargs):
121
115
 
122
116
  with ThreadPoolExecutor() as executor:
123
117
  futures = [
124
- executor.submit(layers.install, input, function) for function in functions
118
+ executor.submit(
119
+ layers.install,
120
+ input._replace(
121
+ session=boto3.Session(
122
+ profile_name=input.aws_profile, region_name=input.aws_region
123
+ )
124
+ ),
125
+ function,
126
+ )
127
+ for function in functions
125
128
  ]
126
129
  install_success = all(future.result() for future in as_completed(futures))
127
130
 
@@ -179,12 +182,6 @@ def uninstall(ctx, **kwargs):
179
182
  """Uninstall New Relic AWS Lambda Layers"""
180
183
  input = LayerUninstall(session=None, verbose=ctx.obj["VERBOSE"], **kwargs)
181
184
 
182
- input = input._replace(
183
- session=boto3.Session(
184
- profile_name=input.aws_profile, region_name=input.aws_region
185
- )
186
- )
187
-
188
185
  if input.aws_permissions_check:
189
186
  permissions.ensure_layer_uninstall_permissions(input)
190
187
 
@@ -192,7 +189,16 @@ def uninstall(ctx, **kwargs):
192
189
 
193
190
  with ThreadPoolExecutor() as executor:
194
191
  futures = [
195
- executor.submit(layers.uninstall, input, function) for function in functions
192
+ executor.submit(
193
+ layers.uninstall,
194
+ input._replace(
195
+ session=boto3.Session(
196
+ profile_name=input.aws_profile, region_name=input.aws_region
197
+ )
198
+ ),
199
+ function,
200
+ )
201
+ for function in functions
196
202
  ]
197
203
  uninstall_success = all(future.result() for future in as_completed(futures))
198
204
 
@@ -37,6 +37,14 @@ def register(group):
37
37
  multiple=True,
38
38
  required=True,
39
39
  )
40
+ @click.option(
41
+ "--stackname",
42
+ default="NewRelicLogIngestion",
43
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
44
+ metavar="<arn>",
45
+ show_default=False,
46
+ required=False,
47
+ )
40
48
  @click.option(
41
49
  "excludes",
42
50
  "--exclude",
@@ -57,12 +65,6 @@ def install(**kwargs):
57
65
  """Install New Relic AWS Lambda Log Subscriptions"""
58
66
  input = SubscriptionInstall(session=None, **kwargs)
59
67
 
60
- input = input._replace(
61
- session=boto3.Session(
62
- profile_name=input.aws_profile, region_name=input.aws_region
63
- )
64
- )
65
-
66
68
  if input.aws_permissions_check:
67
69
  permissions.ensure_subscription_install_permissions(input)
68
70
 
@@ -70,7 +72,15 @@ def install(**kwargs):
70
72
 
71
73
  with ThreadPoolExecutor() as executor:
72
74
  futures = [
73
- executor.submit(subscriptions.create_log_subscription, input, function)
75
+ executor.submit(
76
+ subscriptions.create_log_subscription,
77
+ input._replace(
78
+ session=boto3.Session(
79
+ profile_name=input.aws_profile, region_name=input.aws_region
80
+ )
81
+ ),
82
+ function,
83
+ )
74
84
  for function in functions
75
85
  ]
76
86
  install_success = all(future.result() for future in as_completed(futures))
@@ -92,6 +102,14 @@ def install(**kwargs):
92
102
  multiple=True,
93
103
  required=True,
94
104
  )
105
+ @click.option(
106
+ "--stackname",
107
+ default="NewRelicLogIngestion",
108
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
109
+ metavar="<arn>",
110
+ show_default=False,
111
+ required=False,
112
+ )
95
113
  @click.option(
96
114
  "excludes",
97
115
  "--exclude",
@@ -104,12 +122,6 @@ def uninstall(**kwargs):
104
122
  """Uninstall New Relic AWS Lambda Log Subscriptions"""
105
123
  input = SubscriptionUninstall(session=None, **kwargs)
106
124
 
107
- input = input._replace(
108
- session=boto3.Session(
109
- profile_name=input.aws_profile, region_name=input.aws_region
110
- )
111
- )
112
-
113
125
  if input.aws_permissions_check:
114
126
  permissions.ensure_subscription_uninstall_permissions(input)
115
127
 
@@ -117,7 +129,15 @@ def uninstall(**kwargs):
117
129
 
118
130
  with ThreadPoolExecutor() as executor:
119
131
  futures = [
120
- executor.submit(subscriptions.remove_log_subscription, input, function)
132
+ executor.submit(
133
+ subscriptions.remove_log_subscription,
134
+ input._replace(
135
+ session=boto3.Session(
136
+ profile_name=input.aws_profile, region_name=input.aws_region
137
+ )
138
+ ),
139
+ function,
140
+ )
121
141
  for function in functions
122
142
  ]
123
143
  uninstall_success = all(future.result() for future in as_completed(futures))
@@ -70,8 +70,8 @@ def get_aliased_functions(input):
70
70
  functions = [
71
71
  function
72
72
  for function in input.functions
73
- if function.lower()
74
- not in ("all", "installed", "not-installed", "newrelic-log-ingestion")
73
+ if function.lower() not in ("all", "installed", "not-installed")
74
+ and "newrelic-log-ingestion" not in function.lower()
75
75
  and function not in input.excludes
76
76
  ]
77
77
 
@@ -43,8 +43,8 @@ def _get_role(session, role_name):
43
43
  raise click.UsageError(str(e))
44
44
 
45
45
 
46
- def _check_for_ingest_stack(session):
47
- return _get_cf_stack_status(session, INGEST_STACK_NAME)
46
+ def _check_for_ingest_stack(session, stack_name):
47
+ return _get_cf_stack_status(session, stack_name)
48
48
 
49
49
 
50
50
  def _get_cf_stack_status(session, stack_name, nr_account_id=None):
@@ -86,6 +86,62 @@ def _get_cf_stack_status(session, stack_name, nr_account_id=None):
86
86
  return res["Stacks"][0]["StackStatus"]
87
87
 
88
88
 
89
+ def get_unique_newrelic_log_ingestion_name(session, stackname=None):
90
+ if not stackname:
91
+ stackname = INGEST_STACK_NAME
92
+ stack_id = _get_cf_stack_id(session, stack_name=stackname)
93
+ if stack_id:
94
+ return "newrelic-log-ingestion-%s" % (stack_id.split("/")[2].split("-")[4])
95
+
96
+
97
+ def get_newrelic_log_ingestion_function(session, stackname=None):
98
+ unique_log_ingestion_name = get_unique_newrelic_log_ingestion_name(
99
+ session, stackname
100
+ )
101
+ if unique_log_ingestion_name:
102
+ function = get_function(session, unique_log_ingestion_name)
103
+ return function
104
+
105
+
106
+ def _get_cf_stack_id(session, stack_name, nr_account_id=None):
107
+ """Returns the StackId of the CloudFormation stack if it exists"""
108
+ try:
109
+ res = session.client("cloudformation").describe_stacks(StackName=stack_name)
110
+ if nr_account_id is not None:
111
+ stack_output_account_id = _get_stack_output_value(
112
+ session, ["NrAccountId"]
113
+ ).get("NrAccountId")
114
+ # Checking outputs here to protect against installs done
115
+ # with older CLI versions. We don't want to constantly warn users
116
+ # who installed on previous versions with no outputs.
117
+ if stack_output_account_id and stack_output_account_id != str(
118
+ nr_account_id
119
+ ):
120
+ warning(
121
+ "WARNING: Managed secret already exists in this region for "
122
+ "New Relic account {0}.\n"
123
+ "Current CLI behavior limits the setup of one managed "
124
+ "secret per region.\n"
125
+ "To set up an additional secret for New Relic account {1} "
126
+ "see our docs:\n{2}.\n"
127
+ "Or run this command with --disable-license-key-secret to "
128
+ "avoid attempting to create a new managed secret.".format(
129
+ stack_output_account_id, nr_account_id, NR_DOCS_ACT_LINKING_URL
130
+ )
131
+ )
132
+ except botocore.exceptions.ClientError as e:
133
+ if (
134
+ e.response
135
+ and "ResponseMetadata" in e.response
136
+ and "HTTPStatusCode" in e.response["ResponseMetadata"]
137
+ and e.response["ResponseMetadata"]["HTTPStatusCode"] in (400, 404)
138
+ ):
139
+ return None
140
+ raise click.UsageError(str(e))
141
+ else:
142
+ return res["Stacks"][0]["StackId"]
143
+
144
+
89
145
  # TODO: Merge this with create_integration_role?
90
146
  def _create_role(input):
91
147
  assert isinstance(input, IntegrationInstall)
@@ -200,29 +256,35 @@ def _import_log_ingestion_function(input, nr_license_key):
200
256
  )
201
257
 
202
258
  with open(template_path) as template:
203
- change_set_name = "%s-IMPORT-%d" % (INGEST_STACK_NAME, int(time.time()))
204
- click.echo("Creating change set: %s" % change_set_name)
205
-
206
- change_set = client.create_change_set(
207
- StackName=INGEST_STACK_NAME,
208
- TemplateBody=template.read(),
209
- Parameters=parameters,
210
- Capabilities=capabilities,
211
- Tags=[{"Key": key, "Value": value} for key, value in input.tags]
212
- if input.tags
213
- else [],
214
- ChangeSetType="IMPORT",
215
- ChangeSetName=change_set_name,
216
- ResourcesToImport=[
217
- {
218
- "ResourceType": "AWS::Lambda::Function",
219
- "LogicalResourceId": "NewRelicLogIngestionFunctionNoCap",
220
- "ResourceIdentifier": {"FunctionName": "newrelic-log-ingestion"},
221
- }
222
- ],
259
+ unique_log_ingestion_name = get_unique_newrelic_log_ingestion_name(
260
+ input.session
223
261
  )
262
+ if unique_log_ingestion_name:
263
+ change_set_name = "%s-IMPORT-%d" % (INGEST_STACK_NAME, int(time.time()))
264
+ click.echo("Creating change set: %s" % change_set_name)
265
+
266
+ change_set = client.create_change_set(
267
+ StackName=INGEST_STACK_NAME,
268
+ TemplateBody=template.read(),
269
+ Parameters=parameters,
270
+ Capabilities=capabilities,
271
+ Tags=[{"Key": key, "Value": value} for key, value in input.tags]
272
+ if input.tags
273
+ else [],
274
+ ChangeSetType="IMPORT",
275
+ ChangeSetName=change_set_name,
276
+ ResourcesToImport=[
277
+ {
278
+ "ResourceType": "AWS::Lambda::Function",
279
+ "LogicalResourceId": "NewRelicLogIngestionFunctionNoCap",
280
+ "ResourceIdentifier": {
281
+ "FunctionName": unique_log_ingestion_name
282
+ },
283
+ }
284
+ ],
285
+ )
224
286
 
225
- _exec_change_set(client, change_set, "IMPORT")
287
+ _exec_change_set(client, change_set, "IMPORT")
226
288
 
227
289
 
228
290
  def _create_log_ingestion_function(
@@ -241,11 +303,11 @@ def _create_log_ingestion_function(
241
303
  click.echo("Fetching new CloudFormation template url")
242
304
  template_url = _get_sar_template_url(input.session)
243
305
 
244
- change_set_name = "%s-%s-%d" % (INGEST_STACK_NAME, mode, int(time.time()))
306
+ change_set_name = "%s-%s-%d" % (input.stackname, mode, int(time.time()))
245
307
  click.echo("Creating change set: %s" % change_set_name)
246
308
 
247
309
  change_set = client.create_change_set(
248
- StackName=INGEST_STACK_NAME,
310
+ StackName=input.stackname,
249
311
  TemplateURL=template_url,
250
312
  Parameters=parameters,
251
313
  Capabilities=capabilities,
@@ -256,10 +318,10 @@ def _create_log_ingestion_function(
256
318
  ChangeSetName=change_set_name,
257
319
  )
258
320
 
259
- _exec_change_set(client, change_set, mode)
321
+ _exec_change_set(client, change_set, mode, input.stackname)
260
322
 
261
323
 
262
- def _exec_change_set(client, change_set, mode, stack_name=INGEST_STACK_NAME):
324
+ def _exec_change_set(client, change_set, mode, stack_name):
263
325
  click.echo(
264
326
  "Waiting for change set creation to complete, this may take a minute... ",
265
327
  nl=False,
@@ -324,7 +386,6 @@ def update_log_ingestion_function(input):
324
386
  len(stack_resources) > 0
325
387
  and stack_resources[0]["ResourceType"] == "AWS::CloudFormation::Stack"
326
388
  ):
327
-
328
389
  click.echo("Unwrapping nested stack... ", nl=False)
329
390
 
330
391
  # Set the ingest function itself to disallow deletes
@@ -342,9 +403,24 @@ def update_log_ingestion_function(input):
342
403
 
343
404
  # We can't change props during import, so let's set them to their current values
344
405
  lambda_client = input.session.client("lambda")
345
- old_props = lambda_client.get_function_configuration(
346
- FunctionName="newrelic-log-ingestion"
406
+ unique_log_ingestion_name = get_unique_newrelic_log_ingestion_name(
407
+ input.session
347
408
  )
409
+ old_props = {}
410
+ try:
411
+ old_props = lambda_client.get_function_configuration(
412
+ FunctionName=unique_log_ingestion_name
413
+ )
414
+ except lambda_client.exceptions.ResourceNotFoundException:
415
+ old_props = lambda_client.get_function_configuration(
416
+ FunctionName="newrelic-log-ingestion"
417
+ )
418
+ warning(
419
+ "It looks like an old log ingestion function is present in this region. "
420
+ "Consider manually deleting this as it is no longer used and "
421
+ "has been replaced by a log ingestion function specific to the stack."
422
+ )
423
+
348
424
  old_role_name = old_props["Role"].split("/")[-1]
349
425
  old_nr_license_key = old_props["Environment"]["Variables"]["LICENSE_KEY"]
350
426
  old_enable_logs = False
@@ -424,19 +500,19 @@ def remove_log_ingestion_function(input):
424
500
  assert isinstance(input, IntegrationUninstall)
425
501
 
426
502
  client = input.session.client("cloudformation")
427
- stack_status = _check_for_ingest_stack(input.session)
503
+ stack_status = _check_for_ingest_stack(input.session, input.stackname)
428
504
  if stack_status is None:
429
505
  click.echo(
430
506
  "No New Relic AWS Lambda log ingestion found in region %s, skipping"
431
507
  % input.session.region_name
432
508
  )
433
509
  return
434
- click.echo("Deleting New Relic log ingestion stack '%s'" % INGEST_STACK_NAME)
435
- client.delete_stack(StackName=INGEST_STACK_NAME)
510
+ click.echo("Deleting New Relic log ingestion stack '%s'" % input.stackname)
511
+ client.delete_stack(StackName=input.stackname)
436
512
  click.echo(
437
513
  "Waiting for stack deletion to complete, this may take a minute... ", nl=False
438
514
  )
439
- client.get_waiter("stack_delete_complete").wait(StackName=INGEST_STACK_NAME)
515
+ client.get_waiter("stack_delete_complete").wait(StackName=input.stackname)
440
516
  success("Done")
441
517
 
442
518
 
@@ -518,22 +594,35 @@ def install_log_ingestion(
518
594
  """
519
595
  assert isinstance(input, IntegrationInstall)
520
596
  function = get_function(input.session, "newrelic-log-ingestion")
521
- if function is None:
522
- stack_status = _check_for_ingest_stack(input.session)
523
- if stack_status is None:
524
- click.echo(
525
- "Setting up 'newrelic-log-ingestion' function in region: %s"
526
- % input.session.region_name
597
+ if function:
598
+ warning(
599
+ "It looks like an old log ingestion function is present in this region. "
600
+ "Consider manually deleting this as it is no longer used and "
601
+ "has been replaced by a log ingestion function specific to the stack."
602
+ )
603
+ stack_status = _check_for_ingest_stack(input.session, input.stackname)
604
+ if stack_status is None:
605
+ click.echo(
606
+ "Setting up CloudFormation Stack %s in region: %s"
607
+ % (input.stackname, input.session.region_name)
608
+ )
609
+ try:
610
+ _create_log_ingestion_function(
611
+ input,
612
+ nr_license_key,
527
613
  )
528
- try:
529
- _create_log_ingestion_function(
530
- input,
531
- nr_license_key,
532
- )
533
- except Exception as e:
534
- failure("Failed to create 'newrelic-log-ingestion' function: %s" % e)
535
- return False
536
- else:
614
+ return True
615
+ except Exception as e:
616
+ failure(
617
+ "CloudFormation Stack NewRelicLogIngestion exists (status: %s).\n"
618
+ "Please manually delete the stack and re-run this command."
619
+ % stack_status
620
+ )
621
+ return False
622
+ else:
623
+ function = get_newrelic_log_ingestion_function(input.session)
624
+
625
+ if function is None:
537
626
  failure(
538
627
  "CloudFormation Stack NewRelicLogIngestion exists (status: %s), but "
539
628
  "newrelic-log-ingestion Lambda function does not.\n"
@@ -541,12 +630,13 @@ def install_log_ingestion(
541
630
  % stack_status
542
631
  )
543
632
  return False
544
- else:
545
- success(
546
- "The 'newrelic-log-ingestion' function already exists in region %s, "
547
- "skipping" % input.session.region_name
548
- )
549
- return True
633
+ else:
634
+ success(
635
+ "The CloudFormation Stack NewRelicLogIngestion and "
636
+ "newrelic-log-ingestion function already exists in region %s, "
637
+ "skipping" % input.session.region_name
638
+ )
639
+ return True
550
640
 
551
641
 
552
642
  @catch_boto_errors
@@ -558,16 +648,7 @@ def update_log_ingestion(input):
558
648
  """
559
649
  assert isinstance(input, IntegrationUpdate)
560
650
 
561
- function = get_function(input.session, "newrelic-log-ingestion")
562
- if function is None:
563
- failure(
564
- "No 'newrelic-log-ingestion' function in region '%s'. "
565
- "Run 'newrelic-lambda integrations install' to install it."
566
- % input.session.region_name
567
- )
568
- return False
569
-
570
- stack_status = _check_for_ingest_stack(input.session)
651
+ stack_status = _check_for_ingest_stack(input.session, input.stackname)
571
652
  if stack_status is None:
572
653
  failure(
573
654
  "No 'NewRelicLogIngestion' stack in region '%s'. "
@@ -578,10 +659,19 @@ def update_log_ingestion(input):
578
659
  )
579
660
  return False
580
661
 
662
+ function = get_newrelic_log_ingestion_function(input.session, input.stackname)
663
+ if function is None:
664
+ failure(
665
+ "No newrelic-log-ingestion function in region '%s'. "
666
+ "Run 'newrelic-lambda integrations install' to install it."
667
+ % input.session.region_name
668
+ )
669
+ return False
670
+
581
671
  try:
582
672
  update_log_ingestion_function(input)
583
673
  except Exception as e:
584
- failure("Failed to update 'newrelic-log-ingestion' function: %s" % e)
674
+ failure("Failed to update newrelic-log-ingestion function: %s" % e)
585
675
  return False
586
676
  else:
587
677
  return True
@@ -592,7 +682,7 @@ def get_log_ingestion_license_key(session):
592
682
  """
593
683
  Fetches the license key value from the log ingestion function
594
684
  """
595
- function = get_function(session, "newrelic-log-ingestion")
685
+ function = get_newrelic_log_ingestion_function(session)
596
686
  if function:
597
687
  return function["Configuration"]["Environment"]["Variables"]["LICENSE_KEY"]
598
688
  return None
@@ -153,7 +153,7 @@ def _add_new_relic(input, config, nr_license_key):
153
153
  if any("NewRelicLambdaExtension" in s for s in new_relic_layer):
154
154
  runtime_handler = None
155
155
 
156
- # Only used by Python, Node.js and Java runtimes not using the
156
+ # Only used by Python, Node.js, Ruby, and Java runtimes not using the
157
157
  # NewRelicLambdaExtension layer
158
158
  if runtime_handler:
159
159
  update_kwargs["Handler"] = runtime_handler
@@ -5,6 +5,8 @@ import click
5
5
 
6
6
  from newrelic_lambda_cli.cliutils import failure, success, warning
7
7
  from newrelic_lambda_cli.functions import get_function
8
+ from newrelic_lambda_cli.integrations import get_unique_newrelic_log_ingestion_name
9
+ from newrelic_lambda_cli.integrations import get_newrelic_log_ingestion_function
8
10
  from newrelic_lambda_cli.types import (
9
11
  LayerInstall,
10
12
  SubscriptionInstall,
@@ -83,10 +85,17 @@ def _remove_subscription_filter(session, function_name, filter_name):
83
85
  @catch_boto_errors
84
86
  def create_log_subscription(input, function_name):
85
87
  assert isinstance(input, SubscriptionInstall)
86
- destination = get_function(input.session, "newrelic-log-ingestion")
88
+ function = get_function(input.session, "newrelic-log-ingestion")
89
+ if function:
90
+ warning(
91
+ "It looks like an old log ingestion function is present in this region. "
92
+ "Consider manually deleting this as it is no longer used and "
93
+ "has been replaced by a log ingestion function specific to the stack."
94
+ )
95
+ destination = get_newrelic_log_ingestion_function(input.session, input.stackname)
87
96
  if destination is None:
88
97
  failure(
89
- "Could not find 'newrelic-log-ingestion' function. Is the New Relic AWS "
98
+ "Could not find newrelic-log-ingestion function. Is the New Relic AWS "
90
99
  "integration installed?"
91
100
  )
92
101
  return False
@@ -62,7 +62,7 @@ Resources:
62
62
  Key: 466768951184/arn:aws:serverlessrepo:us-east-1:463657938898:applications-NewRelic-log-ingestion-versions-2.2.1/2dcb4087-186a-42c8-bc1f-cf93780786c0
63
63
  Description: Sends log data from CloudWatch Logs and S3 to New Relic Infrastructure (Cloud integrations) and New Relic Logging
64
64
  Handler: function.lambda_handler
65
- FunctionName: newrelic-log-ingestion
65
+ FunctionName: !Join ['-', ['newrelic-log-ingestion', !Select [4, !Split ['-', !Select [2, !Split ['/', !Ref AWS::StackId]]]]]]
66
66
  MemorySize:
67
67
  Ref: MemorySize
68
68
  Runtime: python3.9
@@ -84,7 +84,7 @@ Resources:
84
84
  Key: 466768951184/arn:aws:serverlessrepo:us-east-1:463657938898:applications-NewRelic-log-ingestion-versions-2.2.1/2dcb4087-186a-42c8-bc1f-cf93780786c0
85
85
  Description: Sends log data from CloudWatch Logs and S3 to New Relic Infrastructure (Cloud integrations) and New Relic Logging
86
86
  Handler: function.lambda_handler
87
- FunctionName: newrelic-log-ingestion
87
+ FunctionName: !Join ['-', ['newrelic-log-ingestion', !Select [4, !Split ['-', !Select [2, !Split ['/', !Ref AWS::StackId]]]]]]
88
88
  MemorySize:
89
89
  Ref: MemorySize
90
90
  Runtime: python3.9
@@ -8,6 +8,7 @@ INTEGRATION_INSTALL_KEYS = [
8
8
  "aws_permissions_check",
9
9
  "aws_role_policy",
10
10
  "enable_logs",
11
+ "stackname",
11
12
  "memory_size",
12
13
  "linked_account_name",
13
14
  "nr_account_id",
@@ -26,6 +27,7 @@ INTEGRATION_UNINSTALL_KEYS = [
26
27
  "aws_profile",
27
28
  "aws_region",
28
29
  "aws_permissions_check",
30
+ "stackname",
29
31
  "nr_account_id",
30
32
  "force",
31
33
  ]
@@ -36,6 +38,7 @@ INTEGRATION_UPDATE_KEYS = [
36
38
  "aws_region",
37
39
  "aws_permissions_check",
38
40
  "enable_logs",
41
+ "stackname",
39
42
  "memory_size",
40
43
  "nr_account_id",
41
44
  "nr_api_key",
@@ -80,6 +83,7 @@ SUBSCRIPTION_INSTALL_KEYS = [
80
83
  "aws_region",
81
84
  "aws_permissions_check",
82
85
  "functions",
86
+ "stackname",
83
87
  "excludes",
84
88
  "filter_pattern",
85
89
  ]
@@ -90,6 +94,7 @@ SUBSCRIPTION_UNINSTALL_KEYS = [
90
94
  "aws_region",
91
95
  "aws_permissions_check",
92
96
  "functions",
97
+ "stackname",
93
98
  "excludes",
94
99
  ]
95
100
 
@@ -10,6 +10,10 @@ NR_DOCS_ACT_LINKING_URL = "https://docs.newrelic.com/docs/serverless-function-mo
10
10
  NEW_RELIC_ARN_PREFIX_TEMPLATE = "arn:aws:lambda:%s:451483290750"
11
11
  RUNTIME_CONFIG = {
12
12
  "dotnetcore3.1": {"LambdaExtension": True},
13
+ "java21": {
14
+ "Handler": "com.newrelic.java.HandlerWrapper::",
15
+ "LambdaExtension": True,
16
+ },
13
17
  "java17": {
14
18
  "Handler": "com.newrelic.java.HandlerWrapper::",
15
19
  "LambdaExtension": True,
@@ -36,6 +40,7 @@ RUNTIME_CONFIG = {
36
40
  },
37
41
  "provided": {"LambdaExtension": True},
38
42
  "provided.al2": {"LambdaExtension": True},
43
+ "provided.al2023": {"LambdaExtension": True},
39
44
  "python3.7": {
40
45
  "Handler": "newrelic_lambda_wrapper.handler",
41
46
  "LambdaExtension": True,
@@ -60,6 +65,14 @@ RUNTIME_CONFIG = {
60
65
  "Handler": "newrelic_lambda_wrapper.handler",
61
66
  "LambdaExtension": True,
62
67
  },
68
+ "ruby3.2": {
69
+ "Handler": "newrelic_lambda_wrapper.handler",
70
+ "LambdaExtension": True,
71
+ },
72
+ "ruby3.3": {
73
+ "Handler": "newrelic_lambda_wrapper.handler",
74
+ "LambdaExtension": True,
75
+ },
63
76
  }
64
77
 
65
78
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newrelic-lambda-cli
3
- Version: 0.8.0
3
+ Version: 0.9.1
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
@@ -46,7 +46,7 @@ A CLI to install the New Relic AWS Lambda integration and layers.
46
46
  * Installs and configures a New Relic AWS Lambda layer onto your AWS Lambda functions
47
47
  * Automatically selects the correct New Relic layer for your function's runtime and region
48
48
  * Wraps your AWS Lambda functions without requiring a code change
49
- * Supports Go, Java, .NET, Node.js and Python AWS Lambda runtimes
49
+ * Supports Go, Java, .NET, Node.js, Python, and Ruby AWS Lambda runtimes
50
50
  * Easily uninstall the AWS Lambda layer with a single command
51
51
 
52
52
  ## Runtimes Supported
@@ -55,6 +55,7 @@ A CLI to install the New Relic AWS Lambda integration and layers.
55
55
  * java8.al2
56
56
  * java11
57
57
  * java17
58
+ * java21
58
59
  * nodejs16.x
59
60
  * nodejs18.x
60
61
  * nodejs20.x
@@ -66,8 +67,10 @@ A CLI to install the New Relic AWS Lambda integration and layers.
66
67
  * python3.10
67
68
  * python3.11
68
69
  * python3.12
70
+ * ruby3.2
71
+ * ruby3.3
69
72
 
70
- **Note:** Automatic handler wrapping is only supported for Node.js, Python and Java. For other runtimes,
73
+ **Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,
71
74
  manual function wrapping is required using the runtime specific New Relic agent.
72
75
 
73
76
  ## Requirements
@@ -132,6 +135,7 @@ newrelic-lambda integrations install \
132
135
  | `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |
133
136
  | `--disable-license-key-secret` | No | Don't create a managed secret for your account's New Relic License Key |
134
137
  | `--tag <key> <value>` | No | Sets tags on the CloudFormation Stacks this CLI creates. Can be used multiple times, example: `--tag key1 value1 --tag key2 value2`. |
138
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicLogIngestion stack |
135
139
 
136
140
  #### Uninstall Integration
137
141
 
@@ -145,6 +149,7 @@ newrelic-lambda integrations uninstall
145
149
  | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
146
150
  | `--force` or `-f` | No | Forces uninstall non-interactively |
147
151
  | `--nr-account-id` or `-a` | No | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) for the integration. Only required if also uninstalling the New Relic AWS Lambda integration. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
152
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicLogIngestion stack |
148
153
 
149
154
  #### Update Integration
150
155
 
@@ -172,6 +177,7 @@ newrelic-lambda integrations update \
172
177
  | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
173
178
  | `--disable-license-key-secret` | No | Disable automatic creation of the license key secret on update. The secret is not created if it exists. |
174
179
  | `--tag <key> <value>` | No | Sets tags on the CloudFormation Stacks this CLI creates. Can be used multiple times, example: `--tag key1 value1 --tag key2 value2`. |
180
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicLogIngestion stack |
175
181
 
176
182
  ### AWS Lambda Layers
177
183
 
@@ -244,6 +250,7 @@ newrelic-lambda subscriptions install --function <name or arn>
244
250
  | Option | Required? | Description |
245
251
  |--------|-----------|-------------|
246
252
  | `--function` or `-f` | Yes | The AWS Lambda function name or ARN in which to add a log subscription. Can provide multiple `--function` arguments. Will also accept `all`, `installed` and `not-installed` similar to `newrelic-lambda functions list`. |
253
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicLogIngestion stack |
247
254
  | `--exclude` or `-e` | No | A function name to exclude while installing subscriptions. Can provide multiple `--exclude` arguments. Only checked when `all`, `installed` and `not-installed` are used. See `newrelic-lambda functions list` for function names. |
248
255
  | `--filter-pattern` | No | Specify a custom log subscription filter pattern. To collect all logs use `--filter-pattern ""`. |
249
256
  | `--aws-profile` or `-p` | No | The AWS profile to use for this command. Can also use `AWS_PROFILE`. Will also check `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables if not using AWS CLI. |
@@ -258,6 +265,7 @@ newrelic-lambda subscriptions uninstall --function <name or arn>
258
265
  | Option | Required? | Description |
259
266
  |--------|-----------|-------------|
260
267
  | `--function` or `-f` | Yes | The AWS Lambda function name or ARN in which to remove a log subscription. Can provide multiple `--function` arguments. Will also accept `all`, `installed` and `not-installed` similar to `newrelic-lambda functions list`. |
268
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicLogIngestion stack |
261
269
  | `--exclude` or `-e` | No | A function name to exclude while uninstalling subscriptions. Can provide multiple `--exclude` arguments. Only checked when `all`, `installed` and `not-installed` are used. See `newrelic-lambda functions list` for function names. |
262
270
  | `--aws-profile` or `-p` | No | The AWS profile to use for this command. Can also use `AWS_PROFILE`. Will also check `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables if not using AWS CLI. |
263
271
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
@@ -0,0 +1,25 @@
1
+ newrelic_lambda_cli/__init__.py,sha256=u4cy7hwbrNjK3xtldGQD_51aoNgSqGQ3IzFYsuvaIM4,149
2
+ newrelic_lambda_cli/api.py,sha256=tkjuR_qkD2uZgXfXPFR6YKnmRiNYkrEmqQEeUgDtNn8,14848
3
+ newrelic_lambda_cli/cliutils.py,sha256=x2pWlL3DJ9t98QNElp_rhawNQoIZ0vd55R2jpo3_oI0,902
4
+ newrelic_lambda_cli/functions.py,sha256=p57ZUw424BaSUA_Gw8DrYsJOYKROEHEaXgARadqwcP0,2800
5
+ newrelic_lambda_cli/integrations.py,sha256=X9OuBK_sNfjb1cjbZ1dctd_YTVyEeCCGsPaJp0Bni1U,30864
6
+ newrelic_lambda_cli/layers.py,sha256=Gnt9pdG1Tfh79Y8ZWWJyMVXEB6xnW2UaSuo5zoYLa3U,14270
7
+ newrelic_lambda_cli/permissions.py,sha256=H7v5IMpKaJIWC4Dff2YcTis4BKAAFIJr9IHWUj1LnF4,9093
8
+ newrelic_lambda_cli/subscriptions.py,sha256=wh6vroU8RfSEwqAMObjPNVPb0TbBxUYYPO_c3mY7miA,6166
9
+ newrelic_lambda_cli/types.py,sha256=kzubT5cGiI-k6h_8b_iTaj3bnsNwolhjgSbpFJT9iBk,2304
10
+ newrelic_lambda_cli/utils.py,sha256=cwYX_zG72EjGT92l43mEAJRygrClUNseKDyssQ6D_2Q,5240
11
+ newrelic_lambda_cli/cli/__init__.py,sha256=n_QPd3oJqkFxryy-pJ-Y_AsqsmgbTb3dlQCjPJueaYQ,544
12
+ newrelic_lambda_cli/cli/decorators.py,sha256=a3agkVfy8omkUSL4aKblwSX95xtxYOGASULDYcJDPHk,1786
13
+ newrelic_lambda_cli/cli/functions.py,sha256=RSh2Cowe1_oQup8q5YRidp03z-BITo2uzvDh4zvLr4I,2601
14
+ newrelic_lambda_cli/cli/integrations.py,sha256=aQAWcCCU2kBmbF8fLKwKB9bzSY0uipvnojajjTkhqEs,10461
15
+ newrelic_lambda_cli/cli/layers.py,sha256=dVlBB0rnhnWEXl9EygEjSiJknNnIQgPbF8L5hsdkMfU,5886
16
+ newrelic_lambda_cli/cli/subscriptions.py,sha256=qwV4WUW9fbju0t4-aSfIrPdeEa4QvIJ8bfwTvMnm7zs,4251
17
+ newrelic_lambda_cli/templates/import-template.yaml,sha256=0r1yeoqpnqtEMggWomALkPG10NiANPWWBqz03rChch8,3771
18
+ newrelic_lambda_cli/templates/license-key-secret.yaml,sha256=ZldQaLXsyF1K2I4X_AsLdH7kRmLkPUYI3talmhqQyHg,1849
19
+ newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml,sha256=s7T73B_k-mAwgzJrD2xn8YGUNgn2E1V7Exifrl81ViU,2874
20
+ newrelic_lambda_cli-0.9.1.dist-info/LICENSE,sha256=uuxDzQm0yfq_tNZX0tQYzsZUVRIF0jm3dBLZUojSYzI,11345
21
+ newrelic_lambda_cli-0.9.1.dist-info/METADATA,sha256=rKXVnaSVtnjbs_5xuj_CdvJh8fRMWEpB5_LAnrTACag,21703
22
+ newrelic_lambda_cli-0.9.1.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
23
+ newrelic_lambda_cli-0.9.1.dist-info/entry_points.txt,sha256=iks2k9Y4WNgIecsDzreIvMV9pGCjwwKTf33LKKvl2A8,65
24
+ newrelic_lambda_cli-0.9.1.dist-info/top_level.txt,sha256=dxX2w58VgSUFiPD8C_lFuY-T2C1kjfeY0xi8iTh0r44,20
25
+ newrelic_lambda_cli-0.9.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,25 +0,0 @@
1
- newrelic_lambda_cli/__init__.py,sha256=u4cy7hwbrNjK3xtldGQD_51aoNgSqGQ3IzFYsuvaIM4,149
2
- newrelic_lambda_cli/api.py,sha256=tkjuR_qkD2uZgXfXPFR6YKnmRiNYkrEmqQEeUgDtNn8,14848
3
- newrelic_lambda_cli/cliutils.py,sha256=x2pWlL3DJ9t98QNElp_rhawNQoIZ0vd55R2jpo3_oI0,902
4
- newrelic_lambda_cli/functions.py,sha256=ZdpzzxbItdbYoDB5t5Ljvkgfo9ZfbUCgOjfaii5KB_c,2773
5
- newrelic_lambda_cli/integrations.py,sha256=SU_r40vaNHAlq8C2PsCQKDNqyYWrvX3js-pnyDWu1Gc,26878
6
- newrelic_lambda_cli/layers.py,sha256=3PHELrt3UNXgEW-9QyzbU50D399CMOAsHnel4N-B84g,14263
7
- newrelic_lambda_cli/permissions.py,sha256=H7v5IMpKaJIWC4Dff2YcTis4BKAAFIJr9IHWUj1LnF4,9093
8
- newrelic_lambda_cli/subscriptions.py,sha256=2l56iK8OHatPlUqI3i1me_uu4jE40c_bK6M2sAlNSo0,5632
9
- newrelic_lambda_cli/types.py,sha256=Tmk32eJ50bwjUTVRVtfz2d3L87k0z2ofDhl5_qspxLY,2219
10
- newrelic_lambda_cli/utils.py,sha256=PeLM-RWqHasGacY84UI1Ut-A5yFRMgoVeFaIbIksrEg,4855
11
- newrelic_lambda_cli/cli/__init__.py,sha256=sQDvBeANz9yzgdsfvLnZN2QwvSOGmk8rEjcEBqU00dA,520
12
- newrelic_lambda_cli/cli/decorators.py,sha256=a3agkVfy8omkUSL4aKblwSX95xtxYOGASULDYcJDPHk,1786
13
- newrelic_lambda_cli/cli/functions.py,sha256=RSh2Cowe1_oQup8q5YRidp03z-BITo2uzvDh4zvLr4I,2601
14
- newrelic_lambda_cli/cli/integrations.py,sha256=I8RcFB090dKhFfCazXcNjTbggoLc7edFEcLoPnHMycI,9497
15
- newrelic_lambda_cli/cli/layers.py,sha256=R9vCMoUD9EYx-tJWoFMmWP-kJjoljg4ciWwgeiBLaXQ,5678
16
- newrelic_lambda_cli/cli/subscriptions.py,sha256=aFX4GFxMpYCYOT0-lziZ6yEJI0zk6qI-7j-gq24ereA,3585
17
- newrelic_lambda_cli/templates/import-template.yaml,sha256=eSqR8HZwQAE2tVMzIguhLY611iddMLYhkRZ_IcsXigw,3591
18
- newrelic_lambda_cli/templates/license-key-secret.yaml,sha256=ZldQaLXsyF1K2I4X_AsLdH7kRmLkPUYI3talmhqQyHg,1849
19
- newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml,sha256=s7T73B_k-mAwgzJrD2xn8YGUNgn2E1V7Exifrl81ViU,2874
20
- newrelic_lambda_cli-0.8.0.dist-info/LICENSE,sha256=uuxDzQm0yfq_tNZX0tQYzsZUVRIF0jm3dBLZUojSYzI,11345
21
- newrelic_lambda_cli-0.8.0.dist-info/METADATA,sha256=qxOJusjXPSRhDeTBDZYowYWJVCCU5knmStJQGUL2pQI,20665
22
- newrelic_lambda_cli-0.8.0.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
23
- newrelic_lambda_cli-0.8.0.dist-info/entry_points.txt,sha256=iks2k9Y4WNgIecsDzreIvMV9pGCjwwKTf33LKKvl2A8,65
24
- newrelic_lambda_cli-0.8.0.dist-info/top_level.txt,sha256=dxX2w58VgSUFiPD8C_lFuY-T2C1kjfeY0xi8iTh0r44,20
25
- newrelic_lambda_cli-0.8.0.dist-info/RECORD,,