newrelic-lambda-cli 0.8.0__tar.gz → 0.9.1__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 (44) hide show
  1. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/PKG-INFO +11 -3
  2. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/README.md +10 -2
  3. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cli/__init__.py +1 -0
  4. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cli/integrations.py +32 -0
  5. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cli/layers.py +20 -14
  6. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cli/subscriptions.py +34 -14
  7. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/functions.py +2 -2
  8. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/integrations.py +157 -67
  9. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/layers.py +1 -1
  10. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/subscriptions.py +11 -2
  11. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/templates/import-template.yaml +2 -2
  12. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/types.py +5 -0
  13. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/utils.py +13 -0
  14. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/PKG-INFO +11 -3
  15. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/setup.py +1 -1
  16. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_integrations.py +33 -9
  17. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_subscriptions.py +11 -0
  18. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_utils.py +1 -0
  19. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/CODE_OF_CONDUCT.md +0 -0
  20. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/CONTRIBUTING.md +0 -0
  21. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/LICENSE +0 -0
  22. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/MANIFEST.in +0 -0
  23. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/THIRD_PARTY_NOTICES.md +0 -0
  24. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/__init__.py +0 -0
  25. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/api.py +0 -0
  26. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cli/decorators.py +0 -0
  27. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cli/functions.py +0 -0
  28. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/cliutils.py +0 -0
  29. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/permissions.py +0 -0
  30. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/templates/license-key-secret.yaml +0 -0
  31. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml +0 -0
  32. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/SOURCES.txt +0 -0
  33. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/dependency_links.txt +0 -0
  34. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/entry_points.txt +0 -0
  35. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/not-zip-safe +0 -0
  36. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/requires.txt +0 -0
  37. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/newrelic_lambda_cli.egg-info/top_level.txt +0 -0
  38. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/pyproject.toml +0 -0
  39. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/setup.cfg +0 -0
  40. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_api.py +0 -0
  41. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_functions.py +0 -0
  42. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_layers.py +0 -0
  43. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/tests/test_new_relic_gql.py +0 -0
  44. {newrelic-lambda-cli-0.8.0 → newrelic_lambda_cli-0.9.1}/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.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. |
@@ -28,7 +28,7 @@ A CLI to install the New Relic AWS Lambda integration and layers.
28
28
  * Installs and configures a New Relic AWS Lambda layer onto your AWS Lambda functions
29
29
  * Automatically selects the correct New Relic layer for your function's runtime and region
30
30
  * Wraps your AWS Lambda functions without requiring a code change
31
- * Supports Go, Java, .NET, Node.js and Python AWS Lambda runtimes
31
+ * Supports Go, Java, .NET, Node.js, Python, and Ruby AWS Lambda runtimes
32
32
  * Easily uninstall the AWS Lambda layer with a single command
33
33
 
34
34
  ## Runtimes Supported
@@ -37,6 +37,7 @@ A CLI to install the New Relic AWS Lambda integration and layers.
37
37
  * java8.al2
38
38
  * java11
39
39
  * java17
40
+ * java21
40
41
  * nodejs16.x
41
42
  * nodejs18.x
42
43
  * nodejs20.x
@@ -48,8 +49,10 @@ A CLI to install the New Relic AWS Lambda integration and layers.
48
49
  * python3.10
49
50
  * python3.11
50
51
  * python3.12
52
+ * ruby3.2
53
+ * ruby3.3
51
54
 
52
- **Note:** Automatic handler wrapping is only supported for Node.js, Python and Java. For other runtimes,
55
+ **Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,
53
56
  manual function wrapping is required using the runtime specific New Relic agent.
54
57
 
55
58
  ## Requirements
@@ -114,6 +117,7 @@ newrelic-lambda integrations install \
114
117
  | `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |
115
118
  | `--disable-license-key-secret` | No | Don't create a managed secret for your account's New Relic License Key |
116
119
  | `--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`. |
120
+ | `--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 |
117
121
 
118
122
  #### Uninstall Integration
119
123
 
@@ -127,6 +131,7 @@ newrelic-lambda integrations uninstall
127
131
  | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
128
132
  | `--force` or `-f` | No | Forces uninstall non-interactively |
129
133
  | `--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. |
134
+ | `--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 |
130
135
 
131
136
  #### Update Integration
132
137
 
@@ -154,6 +159,7 @@ newrelic-lambda integrations update \
154
159
  | `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
155
160
  | `--disable-license-key-secret` | No | Disable automatic creation of the license key secret on update. The secret is not created if it exists. |
156
161
  | `--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`. |
162
+ | `--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 |
157
163
 
158
164
  ### AWS Lambda Layers
159
165
 
@@ -226,6 +232,7 @@ newrelic-lambda subscriptions install --function <name or arn>
226
232
  | Option | Required? | Description |
227
233
  |--------|-----------|-------------|
228
234
  | `--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`. |
235
+ | `--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 |
229
236
  | `--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. |
230
237
  | `--filter-pattern` | No | Specify a custom log subscription filter pattern. To collect all logs use `--filter-pattern ""`. |
231
238
  | `--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. |
@@ -240,6 +247,7 @@ newrelic-lambda subscriptions uninstall --function <name or arn>
240
247
  | Option | Required? | Description |
241
248
  |--------|-----------|-------------|
242
249
  | `--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`. |
250
+ | `--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 |
243
251
  | `--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. |
244
252
  | `--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. |
245
253
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
@@ -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. |
@@ -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.8.0",
9
+ version="0.9.1",
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,
@@ -43,7 +43,7 @@ def test__check_for_ingest_stack_none_when_not_found():
43
43
  )
44
44
  }
45
45
  session = MagicMock(**describe_stack_mock)
46
- assert _check_for_ingest_stack(session) is None
46
+ assert _check_for_ingest_stack(session, "test_stack_name") is None
47
47
 
48
48
 
49
49
  def test__check_for_ingest_stack_status_when_found():
@@ -56,7 +56,7 @@ def test__check_for_ingest_stack_status_when_found():
56
56
  }
57
57
  }
58
58
  session = MagicMock(**describe_stack_mock)
59
- assert _check_for_ingest_stack(session) == "CREATE_COMPLETE"
59
+ assert _check_for_ingest_stack(session, "test_stack_name") == "CREATE_COMPLETE"
60
60
 
61
61
 
62
62
  @patch("newrelic_lambda_cli.integrations.success")
@@ -70,7 +70,11 @@ def test__create_log_ingestion_function__defaults(success_mock):
70
70
 
71
71
  _create_log_ingestion_function(
72
72
  integration_install(
73
- session=session, enable_logs=False, memory_size=128, timeout=30
73
+ session=session,
74
+ enable_logs=False,
75
+ memory_size=128,
76
+ timeout=30,
77
+ stackname="NewRelicLogIngestion",
74
78
  ),
75
79
  "test_key",
76
80
  )
@@ -115,6 +119,7 @@ def test__create_log_ingestion_function__opts(success_mock):
115
119
  memory_size=256,
116
120
  role_name="CustomExecRole",
117
121
  timeout=60,
122
+ stackname="NewRelicLogIngestion",
118
123
  ),
119
124
  "test_key",
120
125
  )
@@ -156,8 +161,8 @@ def test_remove_log_ingestion_function(success_mock):
156
161
  session.assert_has_calls(
157
162
  [
158
163
  call.client("cloudformation"),
159
- call.client().describe_stacks(StackName="NewRelicLogIngestion"),
160
- call.client().delete_stack(StackName="NewRelicLogIngestion"),
164
+ call.client().describe_stacks(StackName=None),
165
+ call.client().delete_stack(StackName=None),
161
166
  ],
162
167
  any_order=True,
163
168
  )
@@ -178,7 +183,7 @@ def test_remove_log_ingestion_function_not_present(success_mock):
178
183
  session.assert_has_calls(
179
184
  [
180
185
  call.client("cloudformation"),
181
- call.client().describe_stacks(StackName="NewRelicLogIngestion"),
186
+ call.client().describe_stacks(StackName=None),
182
187
  ],
183
188
  any_order=True,
184
189
  )
@@ -418,7 +423,15 @@ def test_install_log_ingestion(aws_credentials, mock_function_config):
418
423
 
419
424
  mock_client.get_function.reset_mock(return_value=True)
420
425
  mock_client.get_function.return_value = None
421
- mock_client.describe_stacks.return_value = {"Stacks": [{"StackStatus": "peachy"}]}
426
+ mock_client.describe_stacks.return_value = {
427
+ "Stacks": [
428
+ {
429
+ "StackId": "arn:aws:cloudformation:us-east-2:363096433263:stack/NewRelicLogIngestion/ec0fa5a0-abdb-11ee-9bc5-0625ef1d38db",
430
+ "StackName": "NewRelicLogIngestion",
431
+ "StackStatus": "CREATE_COMPLETE",
432
+ }
433
+ ]
434
+ }
422
435
  assert (
423
436
  install_log_ingestion(
424
437
  integration_install(nr_account_id=123456789, session=mock_session),
@@ -428,7 +441,10 @@ def test_install_log_ingestion(aws_credentials, mock_function_config):
428
441
  )
429
442
 
430
443
  mock_client.describe_stacks.reset_mock(return_value=True)
431
- mock_client.describe_stacks.return_value = {"Stacks": [{"StackStatus": None}]}
444
+ mock_client.describe_stacks.return_value = {
445
+ "Stacks": [{"StackId": None, "StackName": None, "StackStatus": None}]
446
+ }
447
+ mock_client._check_for_ingest_stack.return_value = None
432
448
  assert (
433
449
  install_log_ingestion(
434
450
  integration_install(nr_account_id=123456789, session=mock_session),
@@ -462,7 +478,15 @@ def test_update_log_ingestion(aws_credentials, mock_function_config):
462
478
  )
463
479
 
464
480
  mock_client.describe_stacks.reset_mock(return_value=True)
465
- mock_client.describe_stacks.return_value = {"Stacks": [{"StackStatus": "peachy"}]}
481
+ mock_client.describe_stacks.return_value = {
482
+ "Stacks": [
483
+ {
484
+ "StackId": "arn:aws:cloudformation:us-east-2:363096433263:stack/NewRelicLogIngestion/ec0fa5a0-abdb-11ee-9bc5-0625ef1d38db",
485
+ "StackName": "NewRelicLogIngestion",
486
+ "StackStatus": "CREATE_COMPLETE",
487
+ }
488
+ ]
489
+ }
466
490
 
467
491
  assert (
468
492
  update_log_ingestion(
@@ -21,13 +21,24 @@ def test__get_log_group_name():
21
21
  @patch("newrelic_lambda_cli.subscriptions._create_subscription_filter", autospec=True)
22
22
  @patch("newrelic_lambda_cli.subscriptions._get_subscription_filters", autospec=True)
23
23
  @patch("newrelic_lambda_cli.subscriptions._remove_subscription_filter", autospec=True)
24
+ @patch("newrelic_lambda_cli.integrations.get_function", autospec=True)
24
25
  @patch("newrelic_lambda_cli.subscriptions.get_function", autospec=True)
26
+ @patch(
27
+ "newrelic_lambda_cli.integrations.get_unique_newrelic_log_ingestion_name",
28
+ autospec=True,
29
+ )
25
30
  def test_create_log_subscription(
31
+ mock_get_unique_newrelic_log_ingestion_name,
32
+ mock_subscriptions_get_function,
26
33
  mock_get_function,
27
34
  mock_remove_subscription_filter,
28
35
  mock_get_subscription_filters,
29
36
  mock_create_subscription_filter,
30
37
  ):
38
+ mock_get_unique_newrelic_log_ingestion_name.return_value = "newrelic-log-ingestion"
39
+
40
+ mock_subscriptions_get_function.side_effect = None
41
+
31
42
  mock_get_function.side_effect = (
32
43
  None,
33
44
  {"Configuration": {"FunctionArn": "FooBarBaz"}},
@@ -77,6 +77,7 @@ def test_supports_lambda_extension():
77
77
  supports_lambda_extension(runtime)
78
78
  for runtime in (
79
79
  "dotnetcore3.1",
80
+ "java21",
80
81
  "java17",
81
82
  "java11",
82
83
  "java8.al2",