newrelic-lambda-cli 0.9.8__tar.gz → 0.9.10__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.8 → newrelic_lambda_cli-0.9.10}/PKG-INFO +20 -27
  2. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/README.md +19 -26
  3. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/api.py +5 -4
  4. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/layers.py +36 -4
  5. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/layers.py +57 -3
  6. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/types.py +7 -0
  7. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/utils.py +3 -1
  8. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/PKG-INFO +20 -27
  9. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/setup.py +1 -1
  10. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_layers.py +452 -4
  11. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/CODE_OF_CONDUCT.md +0 -0
  12. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/CONTRIBUTING.md +0 -0
  13. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/LICENSE +0 -0
  14. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/MANIFEST.in +0 -0
  15. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/THIRD_PARTY_NOTICES.md +0 -0
  16. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/__init__.py +0 -0
  17. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/__init__.py +0 -0
  18. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/decorators.py +0 -0
  19. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/functions.py +0 -0
  20. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/integrations.py +0 -0
  21. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/otel_ingestions.py +0 -0
  22. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cli/subscriptions.py +0 -0
  23. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/cliutils.py +0 -0
  24. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/functions.py +0 -0
  25. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/integrations.py +0 -0
  26. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/otel_ingestions.py +0 -0
  27. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/permissions.py +0 -0
  28. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/subscriptions.py +0 -0
  29. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/templates/import-template.yaml +0 -0
  30. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/templates/license-key-secret.yaml +0 -0
  31. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli/templates/nr-lambda-integration-role.yaml +0 -0
  32. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/SOURCES.txt +0 -0
  33. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/dependency_links.txt +0 -0
  34. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/entry_points.txt +0 -0
  35. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/not-zip-safe +0 -0
  36. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/requires.txt +0 -0
  37. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/newrelic_lambda_cli.egg-info/top_level.txt +0 -0
  38. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/pyproject.toml +0 -0
  39. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/setup.cfg +0 -0
  40. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_api.py +0 -0
  41. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_functions.py +0 -0
  42. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_integrations.py +0 -0
  43. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_new_relic_gql.py +0 -0
  44. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_permissions.py +0 -0
  45. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_subscriptions.py +0 -0
  46. {newrelic_lambda_cli-0.9.8 → newrelic_lambda_cli-0.9.10}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: newrelic-lambda-cli
3
- Version: 0.9.8
3
+ Version: 0.9.10
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
@@ -62,37 +62,21 @@ A CLI to install the New Relic AWS Lambda integration and layers.
62
62
 
63
63
  ## Runtimes Supported
64
64
 
65
- * dotnetcore3.1
66
- * dotnet6
67
- * dotnet8
68
- * java8.al2
69
- * java11
70
- * java17
71
- * java21
72
- * nodejs16.x
73
- * nodejs18.x
74
- * nodejs20.x
75
- * nodejs22.x
76
- * provided
77
- * provided.al2
78
- * provided.al2023
79
- * python3.7
80
- * python3.8
81
- * python3.9
82
- * python3.10
83
- * python3.11
84
- * python3.12
85
- * python3.13
86
- * ruby3.2
87
- * ruby3.3
88
- * ruby3.4
65
+ | Runtime | Versions |
66
+ |-------------|------------------------|
67
+ | Python | `python3.7`, `python3.8`, `python3.9`, `python3.10`, `python3.11`, `python3.12`, `python3.13` |
68
+ | Node.js | `nodejs16.x`, `nodejs18.x`, `nodejs20.x`, `nodejs22.x` |
69
+ | .NET | `dotnet3.1`, `dotnet6`, `dotnet8` |
70
+ | Java | `java8.al2`, `java11`, `java17`, `java21` |
71
+ | Provided | `provided`, `provided.al2`, `provided.al2023` |
72
+ | Ruby | `ruby3.2`, `ruby3.3`, `ruby3.4` |
89
73
 
90
74
  **Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,
91
75
  manual function wrapping is required using the runtime specific New Relic agent.
92
76
 
93
77
  ## Requirements
94
78
 
95
- * Python >= 3.3 <= 3.12
79
+ * Python >= 3.7 <= 3.13
96
80
  * Retrieve your [New relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) and [User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
97
81
 
98
82
  ## Recommendations
@@ -142,6 +126,9 @@ newrelic-lambda integrations install \
142
126
  | `--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. |
143
127
  | `--linked-account-name` or `-n` | No | A label for the New Relic Linked Account. This is how this integration will appear in New Relic. Defaults to "New Relic Lambda Integration - <AWS Account ID>". |
144
128
  | `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. This is disabled by default. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
129
+ | `--enable-license-key-secret` | No | Securely manages and store your New Relic license key in `AWS Secrets Manager` |
130
+ | `--enable-cw-ingest` | No | Enable the CloudWatch `log ingest` function |
131
+ | `--disable-cw-ingest` | No | Disable the CloudWatch `log ingest` function |
145
132
  | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
146
133
  | `--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`. |
147
134
  | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
@@ -187,6 +174,7 @@ newrelic-lambda integrations update \
187
174
  | `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |
188
175
  | `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
189
176
  | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. |
177
+ | `--enable-license-key-secret` | No | Securely manages and store your New Relic license key in `AWS Secrets Manager` |
190
178
  | `--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`. |
191
179
  | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. |
192
180
  | `--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. |
@@ -214,11 +202,16 @@ newrelic-lambda layers install \
214
202
  | `--layer-arn` or `-l` | No | Specify a specific layer version ARN to use. This is auto detected by default. |
215
203
  | `--upgrade` or `-u` | No | Permit upgrade to the latest layer version for this region and runtime. |
216
204
  | `--disable-extension` | No | Disable the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). |
217
- | `--enable-extension-function-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
205
+ | `--enable-extension-function-logs` or `--send-function-logs` | No | Enable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
206
+ | `--disable-extension-function-logs` or `--disable-function-logs` | No | Disable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
207
+ | `--send-extension-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
208
+ | `--disable-extension-logs` | No | Disable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
218
209
  | `--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. |
219
210
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
220
211
  | `--nr-api-key` or `-k` | No | 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. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
221
212
  | `--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`. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
213
+ | `--nr-env-delimite` | No | Set `NR_ENV_DELIMITER` environment variable for your Lambda Function |
214
+ | `--nr-tags` | No | Set `NR_TAGS` environment variable for your Lambda Function |
222
215
  | `--java_handler_method` or `-j` | No | For java runtimes only to specify an aws implementation method. Defaults to RequestHandler. Optional inputs are: handleRequest, handleStreamsRequest `--java_handler_method handleStreamsRequest`. |
223
216
  | `--esm` | No | For Node.js functions using ES Modules (ESM), enable the specific ESM wrapper during installation (e.g., using the --esm flag). This sets the Lambda handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. |
224
217
 
@@ -36,37 +36,21 @@ A CLI to install the New Relic AWS Lambda integration and layers.
36
36
 
37
37
  ## Runtimes Supported
38
38
 
39
- * dotnetcore3.1
40
- * dotnet6
41
- * dotnet8
42
- * java8.al2
43
- * java11
44
- * java17
45
- * java21
46
- * nodejs16.x
47
- * nodejs18.x
48
- * nodejs20.x
49
- * nodejs22.x
50
- * provided
51
- * provided.al2
52
- * provided.al2023
53
- * python3.7
54
- * python3.8
55
- * python3.9
56
- * python3.10
57
- * python3.11
58
- * python3.12
59
- * python3.13
60
- * ruby3.2
61
- * ruby3.3
62
- * ruby3.4
39
+ | Runtime | Versions |
40
+ |-------------|------------------------|
41
+ | Python | `python3.7`, `python3.8`, `python3.9`, `python3.10`, `python3.11`, `python3.12`, `python3.13` |
42
+ | Node.js | `nodejs16.x`, `nodejs18.x`, `nodejs20.x`, `nodejs22.x` |
43
+ | .NET | `dotnet3.1`, `dotnet6`, `dotnet8` |
44
+ | Java | `java8.al2`, `java11`, `java17`, `java21` |
45
+ | Provided | `provided`, `provided.al2`, `provided.al2023` |
46
+ | Ruby | `ruby3.2`, `ruby3.3`, `ruby3.4` |
63
47
 
64
48
  **Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,
65
49
  manual function wrapping is required using the runtime specific New Relic agent.
66
50
 
67
51
  ## Requirements
68
52
 
69
- * Python >= 3.3 <= 3.12
53
+ * Python >= 3.7 <= 3.13
70
54
  * Retrieve your [New relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) and [User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
71
55
 
72
56
  ## Recommendations
@@ -116,6 +100,9 @@ newrelic-lambda integrations install \
116
100
  | `--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. |
117
101
  | `--linked-account-name` or `-n` | No | A label for the New Relic Linked Account. This is how this integration will appear in New Relic. Defaults to "New Relic Lambda Integration - <AWS Account ID>". |
118
102
  | `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. This is disabled by default. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
103
+ | `--enable-license-key-secret` | No | Securely manages and store your New Relic license key in `AWS Secrets Manager` |
104
+ | `--enable-cw-ingest` | No | Enable the CloudWatch `log ingest` function |
105
+ | `--disable-cw-ingest` | No | Disable the CloudWatch `log ingest` function |
119
106
  | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
120
107
  | `--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`. |
121
108
  | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
@@ -161,6 +148,7 @@ newrelic-lambda integrations update \
161
148
  | `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |
162
149
  | `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
163
150
  | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. |
151
+ | `--enable-license-key-secret` | No | Securely manages and store your New Relic license key in `AWS Secrets Manager` |
164
152
  | `--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`. |
165
153
  | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. |
166
154
  | `--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. |
@@ -188,11 +176,16 @@ newrelic-lambda layers install \
188
176
  | `--layer-arn` or `-l` | No | Specify a specific layer version ARN to use. This is auto detected by default. |
189
177
  | `--upgrade` or `-u` | No | Permit upgrade to the latest layer version for this region and runtime. |
190
178
  | `--disable-extension` | No | Disable the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). |
191
- | `--enable-extension-function-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
179
+ | `--enable-extension-function-logs` or `--send-function-logs` | No | Enable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
180
+ | `--disable-extension-function-logs` or `--disable-function-logs` | No | Disable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
181
+ | `--send-extension-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
182
+ | `--disable-extension-logs` | No | Disable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
192
183
  | `--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. |
193
184
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
194
185
  | `--nr-api-key` or `-k` | No | 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. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
195
186
  | `--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`. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
187
+ | `--nr-env-delimite` | No | Set `NR_ENV_DELIMITER` environment variable for your Lambda Function |
188
+ | `--nr-tags` | No | Set `NR_TAGS` environment variable for your Lambda Function |
196
189
  | `--java_handler_method` or `-j` | No | For java runtimes only to specify an aws implementation method. Defaults to RequestHandler. Optional inputs are: handleRequest, handleStreamsRequest `--java_handler_method handleStreamsRequest`. |
197
190
  | `--esm` | No | For Node.js functions using ES Modules (ESM), enable the specific ESM wrapper during installation (e.g., using the --esm flag). This sets the Lambda handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. |
198
191
 
@@ -370,11 +370,12 @@ def retrieve_license_key(gql):
370
370
  return __cached_license_key
371
371
  except Exception:
372
372
  raise click.BadParameter(
373
- "Could not retrieve license key from New Relic. Check that your New Relic "
374
- "Account ID is valid and try again.",
373
+ f"For New Relic Account ID: {gql.account_id}. "
374
+ "Could not retrieve INGEST - LICENSE key from New Relic. "
375
+ "Check that your New Relic Account ID and USER key are valid and try again.",
375
376
  ctx=None,
376
- param="nr_account_id",
377
- param_hint="New Relic Account ID",
377
+ param="nr_api_key",
378
+ param_hint="API Key",
378
379
  )
379
380
 
380
381
 
@@ -94,10 +94,42 @@ def register(group):
94
94
  help="Enable/disable the New Relic Lambda Extension",
95
95
  )
96
96
  @click.option(
97
- "--enable-extension-function-logs/--disable-extension-function-logs",
98
- default=False,
99
- show_default=True,
100
- help="Enable/disable sending Lambda function logs via the Extension",
97
+ "--send-extension-logs",
98
+ is_flag=True,
99
+ help="Enable sending extension logs via the New Relic Lambda Extension",
100
+ )
101
+ @click.option(
102
+ "--disable-extension-logs",
103
+ is_flag=True,
104
+ help="Disable sending extension logs via the New Relic Lambda Extension",
105
+ )
106
+ @click.option(
107
+ "--enable-extension-function-logs",
108
+ is_flag=True,
109
+ help="Enable sending Lambda function logs via the New Relic Lambda Extension",
110
+ )
111
+ @click.option(
112
+ "--disable-extension-function-logs",
113
+ is_flag=True,
114
+ help="Disable sending Lambda function logs via the New Relic Lambda Extension",
115
+ )
116
+ @click.option(
117
+ "--nr-tags",
118
+ help="Set NR_TAGS environment variable for Lambda (e.g. key1:value1;key2:value2)",
119
+ )
120
+ @click.option(
121
+ "--nr-env-delimiter",
122
+ help="Set NR_ENV_DELIMITER environment variable for Lambda (e.g. ',' for comma)",
123
+ )
124
+ @click.option(
125
+ "--send-function-logs",
126
+ is_flag=True,
127
+ help="Enable sending Lambda function logs via the New Relic Lambda Extension",
128
+ )
129
+ @click.option(
130
+ "--disable-function-logs",
131
+ is_flag=True,
132
+ help="Disable sending Lambda function logs via the New Relic Lambda Extension",
101
133
  )
102
134
  @click.option(
103
135
  "--java_handler_method",
@@ -18,12 +18,16 @@ from newrelic_lambda_cli.utils import catch_boto_errors
18
18
 
19
19
  NEW_RELIC_ENV_VARS = (
20
20
  "NEW_RELIC_ACCOUNT_ID",
21
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS",
21
22
  "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS",
22
23
  "NEW_RELIC_LAMBDA_EXTENSION_ENABLED",
23
24
  "NEW_RELIC_LAMBDA_HANDLER",
24
25
  "NEW_RELIC_LICENSE_KEY",
25
26
  "NEW_RELIC_LOG_ENDPOINT",
26
27
  "NEW_RELIC_TELEMETRY_ENDPOINT",
28
+ "NEW_RELIC_APM_LAMBDA_MODE",
29
+ "NR_TAGS",
30
+ "NR_ENV_DELIMITER",
27
31
  )
28
32
 
29
33
 
@@ -200,10 +204,52 @@ def _add_new_relic(input, config, nr_license_key):
200
204
  "NEW_RELIC_LAMBDA_EXTENSION_ENABLED"
201
205
  ] = "true"
202
206
 
203
- update_kwargs["Environment"]["Variables"][
204
- "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
205
- ] = ("true" if input.enable_extension_function_logs else "false")
207
+ if not input.upgrade:
208
+ update_kwargs["Environment"]["Variables"][
209
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
210
+ ] = "false"
211
+ elif input.enable_extension_function_logs or input.send_function_logs:
212
+ update_kwargs["Environment"]["Variables"][
213
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
214
+ ] = "true"
215
+ success(
216
+ "Successfully enabled NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS tag to the function"
217
+ )
218
+ elif input.disable_extension_function_logs or input.disable_function_logs:
219
+ update_kwargs["Environment"]["Variables"][
220
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
221
+ ] = "false"
222
+ success(
223
+ "Successfully disabled NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS tag to the function"
224
+ )
225
+
226
+ if not input.upgrade:
227
+ update_kwargs["Environment"]["Variables"][
228
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
229
+ ] = "false"
230
+ elif input.send_extension_logs:
231
+ update_kwargs["Environment"]["Variables"][
232
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
233
+ ] = "true"
234
+ success(
235
+ "Successfully enabled NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS tag to the function"
236
+ )
237
+ elif input.disable_extension_logs:
238
+ update_kwargs["Environment"]["Variables"][
239
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
240
+ ] = "false"
241
+ success(
242
+ "Successfully disabled NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS tag to the function"
243
+ )
206
244
 
245
+ if input.nr_tags:
246
+ update_kwargs["Environment"]["Variables"]["NR_TAGS"] = input.nr_tags
247
+ success("Successfully added NR_TAGS tag to the function")
248
+ if input.nr_env_delimiter:
249
+ update_kwargs["Environment"]["Variables"][
250
+ "NR_ENV_DELIMITER"
251
+ ] = input.nr_env_delimiter
252
+ success("Successfully added NR_ENV_DELIMITER tag to the function")
207
253
  if input.nr_region == "staging":
208
254
  update_kwargs["Environment"]["Variables"][
209
255
  "NEW_RELIC_TELEMETRY_ENDPOINT"
@@ -303,6 +349,14 @@ def install(input, function_arn):
303
349
 
304
350
  try:
305
351
  res = client.update_function_configuration(**update_kwargs)
352
+ if input.apm:
353
+ client.tag_resource(
354
+ Resource=config["Configuration"]["FunctionArn"],
355
+ Tags={
356
+ "NR.Apm.Lambda.Mode": "true",
357
+ },
358
+ )
359
+ success("Successfully added APM tag to the function")
306
360
  except botocore.exceptions.ClientError as e:
307
361
  failure(
308
362
  "Failed to update configuration for '%s': %s"
@@ -107,6 +107,13 @@ LAYER_INSTALL_KEYS = [
107
107
  "apm",
108
108
  "enable_extension",
109
109
  "enable_extension_function_logs",
110
+ "disable_extension_function_logs",
111
+ "nr_tags",
112
+ "nr_env_delimiter",
113
+ "send_function_logs",
114
+ "disable_function_logs",
115
+ "send_extension_logs",
116
+ "disable_extension_logs",
110
117
  "java_handler_method",
111
118
  "esm",
112
119
  ]
@@ -187,7 +187,9 @@ def parse_arn(arn):
187
187
  result["resource"] = elements[5]
188
188
  result["resourcetype"] = None
189
189
  else:
190
- result["resourcetype"], result["resource"] = elements[5].split("/")
190
+ splitted_arn = elements[5].split("/")
191
+ result["resourcetype"] = splitted_arn[0]
192
+ result["resource"] = "/".join(splitted_arn[1:])
191
193
  return result
192
194
 
193
195
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: newrelic-lambda-cli
3
- Version: 0.9.8
3
+ Version: 0.9.10
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
@@ -62,37 +62,21 @@ A CLI to install the New Relic AWS Lambda integration and layers.
62
62
 
63
63
  ## Runtimes Supported
64
64
 
65
- * dotnetcore3.1
66
- * dotnet6
67
- * dotnet8
68
- * java8.al2
69
- * java11
70
- * java17
71
- * java21
72
- * nodejs16.x
73
- * nodejs18.x
74
- * nodejs20.x
75
- * nodejs22.x
76
- * provided
77
- * provided.al2
78
- * provided.al2023
79
- * python3.7
80
- * python3.8
81
- * python3.9
82
- * python3.10
83
- * python3.11
84
- * python3.12
85
- * python3.13
86
- * ruby3.2
87
- * ruby3.3
88
- * ruby3.4
65
+ | Runtime | Versions |
66
+ |-------------|------------------------|
67
+ | Python | `python3.7`, `python3.8`, `python3.9`, `python3.10`, `python3.11`, `python3.12`, `python3.13` |
68
+ | Node.js | `nodejs16.x`, `nodejs18.x`, `nodejs20.x`, `nodejs22.x` |
69
+ | .NET | `dotnet3.1`, `dotnet6`, `dotnet8` |
70
+ | Java | `java8.al2`, `java11`, `java17`, `java21` |
71
+ | Provided | `provided`, `provided.al2`, `provided.al2023` |
72
+ | Ruby | `ruby3.2`, `ruby3.3`, `ruby3.4` |
89
73
 
90
74
  **Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,
91
75
  manual function wrapping is required using the runtime specific New Relic agent.
92
76
 
93
77
  ## Requirements
94
78
 
95
- * Python >= 3.3 <= 3.12
79
+ * Python >= 3.7 <= 3.13
96
80
  * Retrieve your [New relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) and [User API Key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
97
81
 
98
82
  ## Recommendations
@@ -142,6 +126,9 @@ newrelic-lambda integrations install \
142
126
  | `--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. |
143
127
  | `--linked-account-name` or `-n` | No | A label for the New Relic Linked Account. This is how this integration will appear in New Relic. Defaults to "New Relic Lambda Integration - <AWS Account ID>". |
144
128
  | `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. This is disabled by default. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
129
+ | `--enable-license-key-secret` | No | Securely manages and store your New Relic license key in `AWS Secrets Manager` |
130
+ | `--enable-cw-ingest` | No | Enable the CloudWatch `log ingest` function |
131
+ | `--disable-cw-ingest` | No | Disable the CloudWatch `log ingest` function |
145
132
  | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
146
133
  | `--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`. |
147
134
  | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
@@ -187,6 +174,7 @@ newrelic-lambda integrations update \
187
174
  | `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |
188
175
  | `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
189
176
  | `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. |
177
+ | `--enable-license-key-secret` | No | Securely manages and store your New Relic license key in `AWS Secrets Manager` |
190
178
  | `--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`. |
191
179
  | `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. |
192
180
  | `--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. |
@@ -214,11 +202,16 @@ newrelic-lambda layers install \
214
202
  | `--layer-arn` or `-l` | No | Specify a specific layer version ARN to use. This is auto detected by default. |
215
203
  | `--upgrade` or `-u` | No | Permit upgrade to the latest layer version for this region and runtime. |
216
204
  | `--disable-extension` | No | Disable the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). |
217
- | `--enable-extension-function-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
205
+ | `--enable-extension-function-logs` or `--send-function-logs` | No | Enable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
206
+ | `--disable-extension-function-logs` or `--disable-function-logs` | No | Disable sending Lambda function logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
207
+ | `--send-extension-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
208
+ | `--disable-extension-logs` | No | Disable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension).|
218
209
  | `--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. |
219
210
  | `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
220
211
  | `--nr-api-key` or `-k` | No | 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. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
221
212
  | `--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`. Only used if `--enable-extension` is set and there is no New Relic license key in AWS Secrets Manager. |
213
+ | `--nr-env-delimite` | No | Set `NR_ENV_DELIMITER` environment variable for your Lambda Function |
214
+ | `--nr-tags` | No | Set `NR_TAGS` environment variable for your Lambda Function |
222
215
  | `--java_handler_method` or `-j` | No | For java runtimes only to specify an aws implementation method. Defaults to RequestHandler. Optional inputs are: handleRequest, handleStreamsRequest `--java_handler_method handleStreamsRequest`. |
223
216
  | `--esm` | No | For Node.js functions using ES Modules (ESM), enable the specific ESM wrapper during installation (e.g., using the --esm flag). This sets the Lambda handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. |
224
217
 
@@ -6,7 +6,7 @@ README = open(os.path.join(os.path.dirname(__file__), "README.md"), "r").read()
6
6
 
7
7
  setup(
8
8
  name="newrelic-lambda-cli",
9
- version="0.9.8",
9
+ version="0.9.10",
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,
@@ -55,7 +55,7 @@ def test_add_new_relic(aws_credentials, mock_function_config):
55
55
  update_kwargs["Environment"]["Variables"][
56
56
  "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
57
57
  ]
58
- == "true"
58
+ == "false"
59
59
  )
60
60
 
61
61
  config = mock_function_config("not.a.runtime")
@@ -263,6 +263,85 @@ def test_add_new_relic_apm_lambda_mode(aws_credentials, mock_function_config):
263
263
  )
264
264
 
265
265
 
266
+ def test_install_apm(aws_credentials, mock_function_config):
267
+ mock_session = MagicMock()
268
+ mock_session.region_name = "us-east-1"
269
+ expected_tags_after_tagging = {
270
+ "NR.Apm.Lambda.Mode": "true",
271
+ }
272
+
273
+ with patch(
274
+ "newrelic_lambda_cli.layers._get_license_key_outputs"
275
+ ) as mock_get_license_key_outputs:
276
+ mock_client = mock_session.client.return_value
277
+
278
+ mock_client.get_function.reset_mock(return_value=True)
279
+
280
+ config = mock_function_config("python3.12")
281
+ mock_client.get_function.return_value = config
282
+
283
+ mock_get_license_key_outputs.return_value = ("license_arn", "12345", "policy")
284
+
285
+ try:
286
+ install(
287
+ layer_install(
288
+ session=mock_session,
289
+ aws_region="us-east-1",
290
+ nr_account_id=12345,
291
+ apm=True,
292
+ ),
293
+ "APMLambda",
294
+ )
295
+ except UsageError as e:
296
+ print(f"UsageError: {e}")
297
+
298
+ mock_client.get_function.reset_mock()
299
+ config = mock_function_config("python3.12")
300
+ mock_client.get_function.return_value = config
301
+ mock_client.list_tags.return_value = {"Tags": expected_tags_after_tagging}
302
+ assert (
303
+ install(
304
+ layer_install(nr_account_id=12345, session=mock_session), "APMLambda"
305
+ )
306
+ is True
307
+ )
308
+
309
+ mock_client.assert_has_calls([call.get_function(FunctionName="APMLambda")])
310
+ mock_client.assert_has_calls(
311
+ [
312
+ call.update_function_configuration(
313
+ FunctionName="arn:aws:lambda:us-east-1:5558675309:function:aws-python3-dev-hello", # noqa
314
+ Environment={
315
+ "Variables": {
316
+ "EXISTING_ENV_VAR": "Hello World",
317
+ "NEW_RELIC_ACCOUNT_ID": "12345",
318
+ "NEW_RELIC_LAMBDA_HANDLER": "original_handler",
319
+ "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "false",
320
+ "NEW_RELIC_APM_LAMBDA_MODE": "True",
321
+ }
322
+ },
323
+ Layers=ANY,
324
+ Handler="newrelic_lambda_wrapper.handler",
325
+ )
326
+ ]
327
+ )
328
+
329
+ mock_client.assert_has_calls(
330
+ [
331
+ call.tag_resource(
332
+ Resource="arn:aws:lambda:us-east-1:5558675309:function:aws-python3-dev-hello",
333
+ Tags={
334
+ "NR.Apm.Lambda.Mode": "true",
335
+ },
336
+ )
337
+ ]
338
+ )
339
+
340
+ tags_from_list_tags = mock_client.list_tags(Resource="APMLambda")["Tags"]
341
+
342
+ assert tags_from_list_tags == expected_tags_after_tagging
343
+
344
+
266
345
  @mock_aws
267
346
  def test_add_new_relic_dotnet(aws_credentials, mock_function_config):
268
347
  session = boto3.Session(region_name="us-east-1")
@@ -305,7 +384,7 @@ def test_add_new_relic_dotnet(aws_credentials, mock_function_config):
305
384
  update_kwargs["Environment"]["Variables"][
306
385
  "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
307
386
  ]
308
- == "true"
387
+ == "false"
309
388
  )
310
389
 
311
390
  # .NET specific environment variables
@@ -383,7 +462,7 @@ def test_add_new_relic_nodejs(aws_credentials, mock_function_config):
383
462
  update_kwargs_std["Environment"]["Variables"][
384
463
  "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
385
464
  ]
386
- == "true"
465
+ == "false"
387
466
  )
388
467
 
389
468
  # --- Scenario 2: ESM Node.js Handler (ESM enabled) ---
@@ -435,7 +514,7 @@ def test_add_new_relic_nodejs(aws_credentials, mock_function_config):
435
514
  update_kwargs_esm["Environment"]["Variables"][
436
515
  "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
437
516
  ]
438
- == "true"
517
+ == "false"
439
518
  )
440
519
 
441
520
 
@@ -702,3 +781,372 @@ def test_install_success_message_new_layer(aws_credentials, mock_function_config
702
781
  "Successfully installed Layer ARN %s for the function: %s"
703
782
  % (new_layer_arn, function_arn)
704
783
  )
784
+
785
+
786
+ @mock_aws
787
+ def test_extension_logs_flags(aws_credentials, mock_function_config):
788
+ """Test that --send-extension-logs and --disable-extension-logs flags work correctly"""
789
+ session = boto3.Session(region_name="us-east-1")
790
+ nr_account_id = 12345
791
+
792
+ # Test 1: Fresh install with default settings - logs should be disabled by default
793
+ config = mock_function_config("python3.12")
794
+ update_kwargs = _add_new_relic(
795
+ layer_install(
796
+ session=session,
797
+ aws_region="us-east-1",
798
+ nr_account_id=nr_account_id,
799
+ enable_extension=True,
800
+ ),
801
+ config,
802
+ nr_license_key=None,
803
+ )
804
+
805
+ assert (
806
+ update_kwargs["Environment"]["Variables"][
807
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
808
+ ]
809
+ == "false"
810
+ )
811
+
812
+ # Test 2: Fresh install with --send-extension-logs
813
+ config = mock_function_config("python3.12")
814
+ update_kwargs = _add_new_relic(
815
+ layer_install(
816
+ session=session,
817
+ aws_region="us-east-1",
818
+ nr_account_id=nr_account_id,
819
+ enable_extension=True,
820
+ send_extension_logs=True,
821
+ ),
822
+ config,
823
+ nr_license_key=None,
824
+ )
825
+
826
+ assert (
827
+ update_kwargs["Environment"]["Variables"][
828
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
829
+ ]
830
+ == "false"
831
+ )
832
+
833
+ # Test 3: Upgrade with --send-extension-logs - should set to true
834
+ config = mock_function_config("python3.12")
835
+ config["Configuration"]["Environment"]["Variables"][
836
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
837
+ ] = "false"
838
+
839
+ update_kwargs = _add_new_relic(
840
+ layer_install(
841
+ session=session,
842
+ aws_region="us-east-1",
843
+ nr_account_id=nr_account_id,
844
+ enable_extension=True,
845
+ send_extension_logs=True,
846
+ upgrade=True,
847
+ ),
848
+ config,
849
+ nr_license_key=None,
850
+ )
851
+
852
+ assert (
853
+ update_kwargs["Environment"]["Variables"][
854
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
855
+ ]
856
+ == "true"
857
+ )
858
+
859
+ # Test 4: Upgrade with --disable-extension-logs - should set to false
860
+ config = mock_function_config("python3.12")
861
+ config["Configuration"]["Environment"]["Variables"][
862
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
863
+ ] = "true"
864
+
865
+ update_kwargs = _add_new_relic(
866
+ layer_install(
867
+ session=session,
868
+ aws_region="us-east-1",
869
+ nr_account_id=nr_account_id,
870
+ enable_extension=True,
871
+ disable_extension_logs=True,
872
+ upgrade=True,
873
+ ),
874
+ config,
875
+ nr_license_key=None,
876
+ )
877
+
878
+ assert (
879
+ update_kwargs["Environment"]["Variables"][
880
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
881
+ ]
882
+ == "false"
883
+ )
884
+
885
+ # Test 5: Upgrade without flags - should preserve existing value
886
+ config = mock_function_config("python3.12")
887
+ config["Configuration"]["Environment"]["Variables"][
888
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
889
+ ] = "true"
890
+
891
+ update_kwargs = _add_new_relic(
892
+ layer_install(
893
+ session=session,
894
+ aws_region="us-east-1",
895
+ nr_account_id=nr_account_id,
896
+ enable_extension=True,
897
+ upgrade=True,
898
+ ),
899
+ config,
900
+ nr_license_key=None,
901
+ )
902
+
903
+ assert (
904
+ update_kwargs["Environment"]["Variables"][
905
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
906
+ ]
907
+ == "true"
908
+ )
909
+
910
+
911
+ @mock_aws
912
+ def test_function_logs_flags(aws_credentials, mock_function_config):
913
+ """Test that --send-function-logs and --disable-function-logs flags work correctly"""
914
+ session = boto3.Session(region_name="us-east-1")
915
+ nr_account_id = 12345
916
+
917
+ # Test 1: Fresh install with default settings - logs should be disabled by default
918
+ config = mock_function_config("python3.12")
919
+ update_kwargs = _add_new_relic(
920
+ layer_install(
921
+ session=session,
922
+ aws_region="us-east-1",
923
+ nr_account_id=nr_account_id,
924
+ enable_extension=True,
925
+ ),
926
+ config,
927
+ nr_license_key=None,
928
+ )
929
+
930
+ assert (
931
+ update_kwargs["Environment"]["Variables"][
932
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
933
+ ]
934
+ == "false"
935
+ )
936
+
937
+ # Test 2: Fresh install with --send-function-logs - should still be false
938
+ config = mock_function_config("python3.12")
939
+ update_kwargs = _add_new_relic(
940
+ layer_install(
941
+ session=session,
942
+ aws_region="us-east-1",
943
+ nr_account_id=nr_account_id,
944
+ enable_extension=True,
945
+ send_function_logs=True,
946
+ ),
947
+ config,
948
+ nr_license_key=None,
949
+ )
950
+
951
+ assert (
952
+ update_kwargs["Environment"]["Variables"][
953
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
954
+ ]
955
+ == "false"
956
+ )
957
+
958
+ # Test 3: Upgrade with --send-function-logs - should set to true
959
+ config = mock_function_config("python3.12")
960
+ config["Configuration"]["Environment"]["Variables"][
961
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
962
+ ] = "false"
963
+
964
+ update_kwargs = _add_new_relic(
965
+ layer_install(
966
+ session=session,
967
+ aws_region="us-east-1",
968
+ nr_account_id=nr_account_id,
969
+ enable_extension=True,
970
+ send_function_logs=True,
971
+ upgrade=True,
972
+ ),
973
+ config,
974
+ nr_license_key=None,
975
+ )
976
+
977
+ assert (
978
+ update_kwargs["Environment"]["Variables"][
979
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
980
+ ]
981
+ == "true"
982
+ )
983
+
984
+ # Test 4: Upgrade with --disable-function-logs - should set to false
985
+ config = mock_function_config("python3.12")
986
+ config["Configuration"]["Environment"]["Variables"][
987
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
988
+ ] = "true"
989
+
990
+ update_kwargs = _add_new_relic(
991
+ layer_install(
992
+ session=session,
993
+ aws_region="us-east-1",
994
+ nr_account_id=nr_account_id,
995
+ enable_extension=True,
996
+ disable_function_logs=True,
997
+ upgrade=True,
998
+ ),
999
+ config,
1000
+ nr_license_key=None,
1001
+ )
1002
+
1003
+ assert (
1004
+ update_kwargs["Environment"]["Variables"][
1005
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
1006
+ ]
1007
+ == "false"
1008
+ )
1009
+
1010
+ # Test 5: Upgrade without flags - should preserve existing value
1011
+ config = mock_function_config("python3.12")
1012
+ config["Configuration"]["Environment"]["Variables"][
1013
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
1014
+ ] = "true"
1015
+
1016
+ update_kwargs = _add_new_relic(
1017
+ layer_install(
1018
+ session=session,
1019
+ aws_region="us-east-1",
1020
+ nr_account_id=nr_account_id,
1021
+ enable_extension=True,
1022
+ upgrade=True,
1023
+ ),
1024
+ config,
1025
+ nr_license_key=None,
1026
+ )
1027
+
1028
+ assert (
1029
+ update_kwargs["Environment"]["Variables"][
1030
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
1031
+ ]
1032
+ == "true"
1033
+ )
1034
+
1035
+
1036
+ @mock_aws
1037
+ def test_independent_log_settings(aws_credentials, mock_function_config):
1038
+ """Test that function logs and extension logs are independent settings"""
1039
+ session = boto3.Session(region_name="us-east-1")
1040
+ nr_account_id = 12345
1041
+
1042
+ # Test: Upgrade with one flag should not affect the other setting
1043
+ config = mock_function_config("python3.12")
1044
+ config["Configuration"]["Environment"]["Variables"][
1045
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
1046
+ ] = "true"
1047
+ config["Configuration"]["Environment"]["Variables"][
1048
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
1049
+ ] = "true"
1050
+
1051
+ # Set only function logs to false
1052
+ update_kwargs = _add_new_relic(
1053
+ layer_install(
1054
+ session=session,
1055
+ aws_region="us-east-1",
1056
+ nr_account_id=nr_account_id,
1057
+ enable_extension=True,
1058
+ disable_function_logs=True,
1059
+ upgrade=True,
1060
+ ),
1061
+ config,
1062
+ nr_license_key=None,
1063
+ )
1064
+
1065
+ # Function logs should be set to false, extension logs should be preserved
1066
+ assert (
1067
+ update_kwargs["Environment"]["Variables"][
1068
+ "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS"
1069
+ ]
1070
+ == "false"
1071
+ )
1072
+ assert (
1073
+ update_kwargs["Environment"]["Variables"][
1074
+ "NEW_RELIC_EXTENSION_SEND_EXTENSION_LOGS"
1075
+ ]
1076
+ == "true"
1077
+ )
1078
+
1079
+
1080
+ @mock_aws
1081
+ def test_add_new_relic_sets_nr_tags(aws_credentials, mock_function_config):
1082
+ session = boto3.Session(region_name="us-east-1")
1083
+ config = mock_function_config("python3.12")
1084
+ tags_value = "foo:bar;baz:qux"
1085
+
1086
+ update_kwargs = _add_new_relic(
1087
+ layer_install(
1088
+ session=session,
1089
+ aws_region="us-east-1",
1090
+ nr_account_id=12345,
1091
+ enable_extension=True,
1092
+ enable_extension_function_logs=True,
1093
+ nr_tags=tags_value,
1094
+ ),
1095
+ config,
1096
+ nr_license_key=None,
1097
+ )
1098
+
1099
+ assert update_kwargs["Environment"]["Variables"]["NR_TAGS"] == tags_value
1100
+
1101
+
1102
+ @mock_aws
1103
+ def test_add_new_relic_sets_nr_env_delimiter(aws_credentials, mock_function_config):
1104
+ session = boto3.Session(region_name="us-east-1")
1105
+ config = mock_function_config("python3.12")
1106
+ delimiter_value = "|"
1107
+
1108
+ update_kwargs = _add_new_relic(
1109
+ layer_install(
1110
+ session=session,
1111
+ aws_region="us-east-1",
1112
+ nr_account_id=12345,
1113
+ enable_extension=True,
1114
+ enable_extension_function_logs=True,
1115
+ nr_env_delimiter=delimiter_value,
1116
+ ),
1117
+ config,
1118
+ nr_license_key=None,
1119
+ )
1120
+
1121
+ assert (
1122
+ update_kwargs["Environment"]["Variables"]["NR_ENV_DELIMITER"] == delimiter_value
1123
+ )
1124
+
1125
+
1126
+ @mock_aws
1127
+ def test_add_new_relic_sets_both_nr_tags_and_env_delimiter(
1128
+ aws_credentials, mock_function_config
1129
+ ):
1130
+ session = boto3.Session(region_name="us-east-1")
1131
+ config = mock_function_config("python3.12")
1132
+ tags_value = "foo:bar|baz:qux"
1133
+ delimiter_value = "|"
1134
+
1135
+ update_kwargs = _add_new_relic(
1136
+ layer_install(
1137
+ session=session,
1138
+ aws_region="us-east-1",
1139
+ nr_account_id=12345,
1140
+ enable_extension=True,
1141
+ enable_extension_function_logs=True,
1142
+ nr_tags=tags_value,
1143
+ nr_env_delimiter=delimiter_value,
1144
+ ),
1145
+ config,
1146
+ nr_license_key=None,
1147
+ )
1148
+
1149
+ assert update_kwargs["Environment"]["Variables"]["NR_TAGS"] == tags_value
1150
+ assert (
1151
+ update_kwargs["Environment"]["Variables"]["NR_ENV_DELIMITER"] == delimiter_value
1152
+ )