newrelic-lambda-cli 0.9.1__tar.gz → 0.9.3__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.
Files changed (46) hide show
  1. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/PKG-INFO +73 -1
  2. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/README.md +72 -0
  3. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/api.py +14 -1
  4. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cli/__init__.py +8 -1
  5. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cli/layers.py +10 -2
  6. newrelic_lambda_cli-0.9.3/newrelic_lambda_cli/cli/otel_ingestions.py +219 -0
  7. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cli/subscriptions.py +82 -34
  8. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/integrations.py +34 -21
  9. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/layers.py +12 -0
  10. newrelic_lambda_cli-0.9.3/newrelic_lambda_cli/otel_ingestions.py +276 -0
  11. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/subscriptions.py +91 -2
  12. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/types.py +51 -1
  13. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/utils.py +2 -0
  14. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/PKG-INFO +73 -1
  15. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/SOURCES.txt +2 -0
  16. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/setup.py +1 -1
  17. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_layers.py +63 -0
  18. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_subscriptions.py +90 -0
  19. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_utils.py +2 -0
  20. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/CODE_OF_CONDUCT.md +0 -0
  21. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/CONTRIBUTING.md +0 -0
  22. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/LICENSE +0 -0
  23. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/MANIFEST.in +0 -0
  24. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/THIRD_PARTY_NOTICES.md +0 -0
  25. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/__init__.py +0 -0
  26. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cli/decorators.py +0 -0
  27. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cli/functions.py +0 -0
  28. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cli/integrations.py +0 -0
  29. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/cliutils.py +0 -0
  30. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/functions.py +0 -0
  31. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/permissions.py +0 -0
  32. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/templates/import-template.yaml +0 -0
  33. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/templates/license-key-secret.yaml +0 -0
  34. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml +0 -0
  35. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/dependency_links.txt +0 -0
  36. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/entry_points.txt +0 -0
  37. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/not-zip-safe +0 -0
  38. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/requires.txt +0 -0
  39. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/newrelic_lambda_cli.egg-info/top_level.txt +0 -0
  40. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/pyproject.toml +0 -0
  41. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/setup.cfg +0 -0
  42. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_api.py +0 -0
  43. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_functions.py +0 -0
  44. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_integrations.py +0 -0
  45. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_new_relic_gql.py +0 -0
  46. {newrelic_lambda_cli-0.9.1 → newrelic_lambda_cli-0.9.3}/tests/test_permissions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: newrelic-lambda-cli
3
- Version: 0.9.1
3
+ Version: 0.9.3
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
@@ -34,6 +34,9 @@ A CLI to install the New Relic AWS Lambda integration and layers.
34
34
  * [AWS Lambda Layers](#aws-lambda-layers)
35
35
  * [AWS Lambda Functions](#aws-lambda-functions)
36
36
  * [NewRelic Log Subscription](#newRelic-log-subscription)
37
+ * [NewRelic Otel Log Ingestions](#newRelic-otel-ingestions-install)
38
+ * [NewRelic Otel Log Subscription](#newRelic-otel-log-subscription)
39
+
37
40
  * **[Docker](#docker)**
38
41
  * **[Contributing](#contributing)**
39
42
  * **[Code Style](#code-style)**
@@ -52,6 +55,8 @@ A CLI to install the New Relic AWS Lambda integration and layers.
52
55
  ## Runtimes Supported
53
56
 
54
57
  * dotnetcore3.1
58
+ * dotnet6
59
+ * dotnet8
55
60
  * java8.al2
56
61
  * java11
57
62
  * java17
@@ -61,6 +66,7 @@ A CLI to install the New Relic AWS Lambda integration and layers.
61
66
  * nodejs20.x
62
67
  * provided
63
68
  * provided.al2
69
+ * provided.al2023
64
70
  * python3.7
65
71
  * python3.8
66
72
  * python3.9
@@ -270,6 +276,72 @@ newrelic-lambda subscriptions uninstall --function <name or arn>
270
276
  | `--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. |
271
277
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
272
278
 
279
+ ### NewRelic Otel Ingestions Install
280
+
281
+ #### Install Otel Log Ingestion
282
+
283
+ ```bash
284
+ newrelic-lambda otel-ingestions install \
285
+ --nr-account-id <account id> \
286
+ --nr-api-key <api key>
287
+ ```
288
+
289
+ | Option | Required? | Description |
290
+ |--------|-----------|-------------|
291
+ | `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) for this integration. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
292
+ | `--nr-api-key` or `-k` | Yes | Your [New Relic User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key). Can also use the `NEW_RELIC_API_KEY` environment variable. |
293
+ | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
294
+ | `--nr-region` | No | The New Relic region to use for the integration. Can use the `NEW_RELIC_REGION` environment variable. Can be either `eu` or `us`. Defaults to `us`. |
295
+ | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
296
+ | `--role-name` | No | Role name for the ingestion function. If you prefer to create and manage an IAM role for the function to assume out of band, do so and specify that role's name here. This avoids needing CAPABILITY_IAM. |
297
+ | `--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. |
298
+ | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
299
+ | `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |
300
+ | `--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`. |
301
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
302
+
303
+
304
+ #### Uninstall Otel Log Ingestion
305
+
306
+ ```bash
307
+ newrelic-lambda otel-ingestions uninstall
308
+ ```
309
+
310
+ | Option | Required? | Description |
311
+ |--------|-----------|-------------|
312
+ | `--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. |
313
+ | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
314
+ | `--force` or `-f` | No | Forces uninstall non-interactively |
315
+ | `--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. |
316
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
317
+
318
+ ### NewRelic Otel Log Subscription
319
+
320
+ #### Install Otel Log Subscription
321
+
322
+ ```bash
323
+ newrelic-lambda subscriptions install --function <name or arn> --otel
324
+ ```
325
+
326
+ | Option | Required? | Description |
327
+ |--------|-----------|-------------|
328
+ | `--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`. |
329
+ | `--otel` or `-o` | Yes | Use this flag to install subscription filters for Lambdas that are instrumented with OpenTelemetry (Otel) |
330
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
331
+
332
+
333
+ #### Uninstall Otel Log Subscription
334
+
335
+ ```bash
336
+ newrelic-lambda subscriptions uninstall --function <name or arn> --otel
337
+ ```
338
+
339
+ | Option | Required? | Description |
340
+ |--------|-----------|-------------|
341
+ | `--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`. |
342
+ | `--otel` or `-o` | Yes | Use this flag to install subscription filters for Lambdas that are instrumented with OpenTelemetry (Otel) |
343
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
344
+
273
345
  ## Docker
274
346
 
275
347
  Now, you can run newrelic-lambda-cli as a container.
@@ -16,6 +16,9 @@ A CLI to install the New Relic AWS Lambda integration and layers.
16
16
  * [AWS Lambda Layers](#aws-lambda-layers)
17
17
  * [AWS Lambda Functions](#aws-lambda-functions)
18
18
  * [NewRelic Log Subscription](#newRelic-log-subscription)
19
+ * [NewRelic Otel Log Ingestions](#newRelic-otel-ingestions-install)
20
+ * [NewRelic Otel Log Subscription](#newRelic-otel-log-subscription)
21
+
19
22
  * **[Docker](#docker)**
20
23
  * **[Contributing](#contributing)**
21
24
  * **[Code Style](#code-style)**
@@ -34,6 +37,8 @@ A CLI to install the New Relic AWS Lambda integration and layers.
34
37
  ## Runtimes Supported
35
38
 
36
39
  * dotnetcore3.1
40
+ * dotnet6
41
+ * dotnet8
37
42
  * java8.al2
38
43
  * java11
39
44
  * java17
@@ -43,6 +48,7 @@ A CLI to install the New Relic AWS Lambda integration and layers.
43
48
  * nodejs20.x
44
49
  * provided
45
50
  * provided.al2
51
+ * provided.al2023
46
52
  * python3.7
47
53
  * python3.8
48
54
  * python3.9
@@ -252,6 +258,72 @@ newrelic-lambda subscriptions uninstall --function <name or arn>
252
258
  | `--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. |
253
259
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
254
260
 
261
+ ### NewRelic Otel Ingestions Install
262
+
263
+ #### Install Otel Log Ingestion
264
+
265
+ ```bash
266
+ newrelic-lambda otel-ingestions install \
267
+ --nr-account-id <account id> \
268
+ --nr-api-key <api key>
269
+ ```
270
+
271
+ | Option | Required? | Description |
272
+ |--------|-----------|-------------|
273
+ | `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) for this integration. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
274
+ | `--nr-api-key` or `-k` | Yes | Your [New Relic User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key). Can also use the `NEW_RELIC_API_KEY` environment variable. |
275
+ | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
276
+ | `--nr-region` | No | The New Relic region to use for the integration. Can use the `NEW_RELIC_REGION` environment variable. Can be either `eu` or `us`. Defaults to `us`. |
277
+ | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
278
+ | `--role-name` | No | Role name for the ingestion function. If you prefer to create and manage an IAM role for the function to assume out of band, do so and specify that role's name here. This avoids needing CAPABILITY_IAM. |
279
+ | `--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. |
280
+ | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
281
+ | `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |
282
+ | `--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`. |
283
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
284
+
285
+
286
+ #### Uninstall Otel Log Ingestion
287
+
288
+ ```bash
289
+ newrelic-lambda otel-ingestions uninstall
290
+ ```
291
+
292
+ | Option | Required? | Description |
293
+ |--------|-----------|-------------|
294
+ | `--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. |
295
+ | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
296
+ | `--force` or `-f` | No | Forces uninstall non-interactively |
297
+ | `--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. |
298
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
299
+
300
+ ### NewRelic Otel Log Subscription
301
+
302
+ #### Install Otel Log Subscription
303
+
304
+ ```bash
305
+ newrelic-lambda subscriptions install --function <name or arn> --otel
306
+ ```
307
+
308
+ | Option | Required? | Description |
309
+ |--------|-----------|-------------|
310
+ | `--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`. |
311
+ | `--otel` or `-o` | Yes | Use this flag to install subscription filters for Lambdas that are instrumented with OpenTelemetry (Otel) |
312
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
313
+
314
+
315
+ #### Uninstall Otel Log Subscription
316
+
317
+ ```bash
318
+ newrelic-lambda subscriptions uninstall --function <name or arn> --otel
319
+ ```
320
+
321
+ | Option | Required? | Description |
322
+ |--------|-----------|-------------|
323
+ | `--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`. |
324
+ | `--otel` or `-o` | Yes | Use this flag to install subscription filters for Lambdas that are instrumented with OpenTelemetry (Otel) |
325
+ | `--stackname` | No | The AWS Cloudformation stack name which contains the newrelic-aws-otel-log-ingestion lambda function. If no value is provided, the command searches for the NewRelicOtelLogIngestion stack |
326
+
255
327
  ## Docker
256
328
 
257
329
  Now, you can run newrelic-lambda-cli as a container.
@@ -21,6 +21,9 @@ from newrelic_lambda_cli.types import (
21
21
  IntegrationInstall,
22
22
  IntegrationUpdate,
23
23
  LayerInstall,
24
+ OtelIngestionInstall,
25
+ OtelIngestionUninstall,
26
+ OtelIngestionUpdate,
24
27
  )
25
28
  from newrelic_lambda_cli.utils import parse_arn
26
29
 
@@ -333,7 +336,17 @@ class NewRelicGQL(object):
333
336
 
334
337
 
335
338
  def validate_gql_credentials(input):
336
- assert isinstance(input, (IntegrationInstall, IntegrationUpdate, LayerInstall))
339
+
340
+ assert isinstance(
341
+ input,
342
+ (
343
+ IntegrationInstall,
344
+ IntegrationUpdate,
345
+ LayerInstall,
346
+ OtelIngestionInstall,
347
+ OtelIngestionUpdate,
348
+ ),
349
+ )
337
350
 
338
351
  try:
339
352
  return NewRelicGQL(input.nr_account_id, input.nr_api_key, input.nr_region)
@@ -2,7 +2,13 @@
2
2
 
3
3
  import click
4
4
 
5
- from newrelic_lambda_cli.cli import functions, integrations, layers, subscriptions
5
+ from newrelic_lambda_cli.cli import (
6
+ functions,
7
+ integrations,
8
+ layers,
9
+ otel_ingestions,
10
+ subscriptions,
11
+ )
6
12
 
7
13
 
8
14
  @click.group()
@@ -17,6 +23,7 @@ def cli(ctx, verbose):
17
23
  def register_groups(group):
18
24
  functions.register(group)
19
25
  integrations.register(group)
26
+ otel_ingestions.register(group)
20
27
  layers.register(group)
21
28
  subscriptions.register(group)
22
29
 
@@ -107,7 +107,11 @@ def register(group):
107
107
  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
+ input = input._replace(
111
+ session=boto3.Session(
112
+ profile_name=input.aws_profile, region_name=input.aws_region
113
+ )
114
+ )
111
115
  if input.aws_permissions_check:
112
116
  permissions.ensure_layer_install_permissions(input)
113
117
 
@@ -181,7 +185,11 @@ def install(ctx, **kwargs):
181
185
  def uninstall(ctx, **kwargs):
182
186
  """Uninstall New Relic AWS Lambda Layers"""
183
187
  input = LayerUninstall(session=None, verbose=ctx.obj["VERBOSE"], **kwargs)
184
-
188
+ input = input._replace(
189
+ session=boto3.Session(
190
+ profile_name=input.aws_profile, region_name=input.aws_region
191
+ )
192
+ )
185
193
  if input.aws_permissions_check:
186
194
  permissions.ensure_layer_uninstall_permissions(input)
187
195
 
@@ -0,0 +1,219 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import boto3
4
+ import click
5
+
6
+ from newrelic_lambda_cli import api, otel_ingestions, permissions, integrations
7
+ from newrelic_lambda_cli.types import (
8
+ OtelIngestionInstall,
9
+ OtelIngestionUninstall,
10
+ OtelIngestionUpdate,
11
+ )
12
+ from newrelic_lambda_cli.cli.decorators import add_options, AWS_OPTIONS, NR_OPTIONS
13
+ from newrelic_lambda_cli.cliutils import done, failure
14
+
15
+
16
+ @click.group(name="otel-ingestions")
17
+ def ingestion_group():
18
+ """Manage New Relic AWS Lambda Otel Log Ingestion lambda"""
19
+ pass
20
+
21
+
22
+ def register(group):
23
+ group.add_command(ingestion_group)
24
+ ingestion_group.add_command(install)
25
+ ingestion_group.add_command(uninstall)
26
+ ingestion_group.add_command(update)
27
+
28
+
29
+ @click.command(name="install")
30
+ @add_options(AWS_OPTIONS)
31
+ @click.option(
32
+ "--aws-role-policy",
33
+ help="Alternative AWS role policy to use for integration",
34
+ metavar="<arn>",
35
+ )
36
+ @click.option(
37
+ "--stackname",
38
+ default=otel_ingestions.OTEL_INGEST_STACK_NAME,
39
+ help=f"The AWS Cloudformation stack name which contains the {otel_ingestions.OTEL_INGEST_LAMBDA_NAME} lambda function",
40
+ metavar="<arn>",
41
+ show_default=False,
42
+ required=False,
43
+ )
44
+ @click.option(
45
+ "--memory-size",
46
+ "-m",
47
+ default=128,
48
+ help="Memory size (in MiB) for the log ingestion function",
49
+ metavar="<size>",
50
+ show_default=True,
51
+ type=click.INT,
52
+ )
53
+ @add_options(NR_OPTIONS)
54
+ @click.option(
55
+ "--timeout",
56
+ "-t",
57
+ default=30,
58
+ help="Timeout (in seconds) for the New Relic log ingestion function",
59
+ metavar="<secs>",
60
+ show_default=True,
61
+ type=click.INT,
62
+ )
63
+ @click.option(
64
+ "--role-name",
65
+ default=None,
66
+ help="The name of a pre-created execution role for the log ingest function",
67
+ metavar="<role_name>",
68
+ show_default=False,
69
+ )
70
+ @click.option(
71
+ "--tag",
72
+ "tags",
73
+ default=[],
74
+ help="A tag to be added to the CloudFormation Stack (can be used multiple times)",
75
+ metavar="<key> <value>",
76
+ multiple=True,
77
+ nargs=2,
78
+ )
79
+ @click.pass_context
80
+ def install(ctx, **kwargs):
81
+ """Install New Relic AWS OTEL Ingestion Lambda"""
82
+ input = OtelIngestionInstall(session=None, verbose=ctx.obj["VERBOSE"], **kwargs)
83
+
84
+ input = input._replace(
85
+ session=boto3.Session(
86
+ profile_name=input.aws_profile, region_name=input.aws_region
87
+ )
88
+ )
89
+
90
+ if input.aws_permissions_check:
91
+ permissions.ensure_integration_install_permissions(input)
92
+
93
+ click.echo("Validating New Relic credentials")
94
+ gql_client = api.validate_gql_credentials(input)
95
+
96
+ click.echo("Retrieving integration license key")
97
+ nr_license_key = api.retrieve_license_key(gql_client)
98
+
99
+ install_success = True
100
+
101
+ click.echo(
102
+ f"Creating {otel_ingestions.OTEL_INGEST_LAMBDA_NAME} Lambda function in AWS account"
103
+ )
104
+ res = otel_ingestions.install_otel_log_ingestion(input, nr_license_key)
105
+ install_success = res and install_success
106
+
107
+
108
+ @click.command(name="uninstall")
109
+ @add_options(AWS_OPTIONS)
110
+ @click.option(
111
+ "--nr-account-id",
112
+ "-a",
113
+ envvar="NEW_RELIC_ACCOUNT_ID",
114
+ help="New Relic Account ID",
115
+ metavar="<id>",
116
+ required=False,
117
+ type=click.INT,
118
+ )
119
+ @click.option(
120
+ "--stackname",
121
+ default=otel_ingestions.OTEL_INGEST_STACK_NAME,
122
+ help=f"The AWS Cloudformation stack name which contains the {otel_ingestions.OTEL_INGEST_LAMBDA_NAME} lambda function",
123
+ metavar="<arn>",
124
+ show_default=False,
125
+ required=False,
126
+ )
127
+ @click.option("--force", "-f", help="Force uninstall non-interactively", is_flag=True)
128
+ def uninstall(**kwargs):
129
+ """Uninstall New Relic AWS OTEL Ingestion Lambda"""
130
+ input = OtelIngestionUninstall(session=None, **kwargs)
131
+
132
+ input = input._replace(
133
+ session=boto3.Session(
134
+ profile_name=input.aws_profile, region_name=input.aws_region
135
+ )
136
+ )
137
+
138
+ if input.aws_permissions_check:
139
+ permissions.ensure_integration_uninstall_permissions(input)
140
+
141
+ integrations.remove_log_ingestion_function(input, otel=True)
142
+
143
+ done("Uninstall Complete")
144
+
145
+
146
+ @click.command(name="update")
147
+ @add_options(AWS_OPTIONS)
148
+ @click.option(
149
+ "--stackname",
150
+ default=otel_ingestions.OTEL_INGEST_STACK_NAME,
151
+ help=f"The AWS Cloudformation stack name which contains the {otel_ingestions.OTEL_INGEST_LAMBDA_NAME} lambda function",
152
+ metavar="<arn>",
153
+ show_default=False,
154
+ required=False,
155
+ )
156
+ @click.option(
157
+ "--memory-size",
158
+ "-m",
159
+ help="Memory size (in MiB) for the log ingestion function",
160
+ metavar="<size>",
161
+ type=click.INT,
162
+ )
163
+ @add_options(NR_OPTIONS)
164
+ @click.option(
165
+ "--timeout",
166
+ "-t",
167
+ help="Timeout (in seconds) for the New Relic log ingestion function",
168
+ metavar="<secs>",
169
+ type=click.INT,
170
+ )
171
+ @click.option(
172
+ "--role-name",
173
+ default=None,
174
+ help="The name of a new pre-created execution role for the log ingest function",
175
+ metavar="<role_name>",
176
+ show_default=False,
177
+ )
178
+ @click.option(
179
+ "--stackname",
180
+ default="NewRelicOtelLogIngestion",
181
+ help="The AWS Cloudformation stack name which contains the newrelic-log-ingestion lambda function",
182
+ metavar="<arn>",
183
+ show_default=False,
184
+ required=False,
185
+ )
186
+ @click.option(
187
+ "--tag",
188
+ "tags",
189
+ default=[],
190
+ help="A tag to be added to the CloudFormation Stack (can be used multiple times)",
191
+ metavar="<key> <value>",
192
+ multiple=True,
193
+ nargs=2,
194
+ )
195
+ def update(**kwargs):
196
+ """UpdateNew New Relic AWS OTEL Ingestion Lambda"""
197
+ input = OtelIngestionUpdate(session=None, **kwargs)
198
+
199
+ input = input._replace(
200
+ session=boto3.Session(
201
+ profile_name=input.aws_profile, region_name=input.aws_region
202
+ )
203
+ )
204
+
205
+ if input.aws_permissions_check:
206
+ permissions.ensure_integration_install_permissions(input)
207
+
208
+ update_success = True
209
+
210
+ click.echo(
211
+ f"Updating {otel_ingestions.OTEL_INGEST_LAMBDA_NAME} Lambda function in AWS account"
212
+ )
213
+ res = otel_ingestions.update_otel_log_ingestion(input)
214
+ update_success = res and update_success
215
+
216
+ if update_success:
217
+ done("Update Complete")
218
+ else:
219
+ failure("Update Incomplete. See messages above for details.", exit=True)
@@ -61,28 +61,60 @@ def register(group):
61
61
  metavar="<pattern>",
62
62
  show_default=False,
63
63
  )
64
+ @click.option(
65
+ "--otel",
66
+ "-o",
67
+ help="Subscribe to OTEL log ingestion function",
68
+ is_flag=True,
69
+ )
64
70
  def install(**kwargs):
65
71
  """Install New Relic AWS Lambda Log Subscriptions"""
66
72
  input = SubscriptionInstall(session=None, **kwargs)
67
-
73
+ if input.otel and input.filter_pattern == DEFAULT_FILTER_PATTERN:
74
+ input = input._replace(
75
+ filter_pattern="",
76
+ )
77
+ if input.otel and input.stackname == "NewRelicLogIngestion":
78
+ input = input._replace(
79
+ stackname="NewRelicOtelLogIngestion",
80
+ )
81
+ input = input._replace(
82
+ session=boto3.Session(
83
+ profile_name=input.aws_profile, region_name=input.aws_region
84
+ )
85
+ )
68
86
  if input.aws_permissions_check:
69
87
  permissions.ensure_subscription_install_permissions(input)
70
88
 
71
89
  functions = get_aliased_functions(input)
72
90
 
73
91
  with ThreadPoolExecutor() as executor:
74
- futures = [
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
- )
84
- for function in functions
85
- ]
92
+ if input.otel:
93
+ futures = [
94
+ executor.submit(
95
+ subscriptions.create_otel_log_subscription,
96
+ input._replace(
97
+ session=boto3.Session(
98
+ profile_name=input.aws_profile, region_name=input.aws_region
99
+ )
100
+ ),
101
+ function,
102
+ )
103
+ for function in functions
104
+ ]
105
+ else:
106
+ futures = [
107
+ executor.submit(
108
+ subscriptions.create_log_subscription,
109
+ input._replace(
110
+ session=boto3.Session(
111
+ profile_name=input.aws_profile, region_name=input.aws_region
112
+ )
113
+ ),
114
+ function,
115
+ )
116
+ for function in functions
117
+ ]
86
118
  install_success = all(future.result() for future in as_completed(futures))
87
119
 
88
120
  if install_success:
@@ -102,14 +134,6 @@ def install(**kwargs):
102
134
  multiple=True,
103
135
  required=True,
104
136
  )
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
- )
113
137
  @click.option(
114
138
  "excludes",
115
139
  "--exclude",
@@ -118,28 +142,52 @@ def install(**kwargs):
118
142
  metavar="<name>",
119
143
  multiple=True,
120
144
  )
145
+ @click.option(
146
+ "--otel",
147
+ "-o",
148
+ help="Subscribe to OTEL log ingestion function",
149
+ is_flag=True,
150
+ )
121
151
  def uninstall(**kwargs):
122
152
  """Uninstall New Relic AWS Lambda Log Subscriptions"""
123
153
  input = SubscriptionUninstall(session=None, **kwargs)
124
-
154
+ input = input._replace(
155
+ session=boto3.Session(
156
+ profile_name=input.aws_profile, region_name=input.aws_region
157
+ )
158
+ )
125
159
  if input.aws_permissions_check:
126
160
  permissions.ensure_subscription_uninstall_permissions(input)
127
161
 
128
162
  functions = get_aliased_functions(input)
129
163
 
130
164
  with ThreadPoolExecutor() as executor:
131
- futures = [
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
- )
141
- for function in functions
142
- ]
165
+ if input.otel:
166
+ futures = [
167
+ executor.submit(
168
+ subscriptions.remove_otel_log_subscription,
169
+ input._replace(
170
+ session=boto3.Session(
171
+ profile_name=input.aws_profile, region_name=input.aws_region
172
+ )
173
+ ),
174
+ function,
175
+ )
176
+ for function in functions
177
+ ]
178
+ else:
179
+ futures = [
180
+ executor.submit(
181
+ subscriptions.remove_log_subscription,
182
+ input._replace(
183
+ session=boto3.Session(
184
+ profile_name=input.aws_profile, region_name=input.aws_region
185
+ )
186
+ ),
187
+ function,
188
+ )
189
+ for function in functions
190
+ ]
143
191
  uninstall_success = all(future.result() for future in as_completed(futures))
144
192
 
145
193
  if uninstall_success: