Skip to content

Commit 8c7e965

Browse files
author
Matt Whelan
authored
Merge pull request #88 from newrelic/mwhelan/unnest
Change newrelic-log-ingestion install mechanism
2 parents d9b724a + 9d87ffc commit 8c7e965

File tree

9 files changed

+610
-207
lines changed

9 files changed

+610
-207
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ newrelic-lambda integrations install \
9696
| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
9797
| `--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`. |
9898
| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
99+
| `--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. |
99100
| `--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. |
100101
| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
101102
| `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |
@@ -115,23 +116,23 @@ newrelic-lambda integrations uninstall
115116

116117
#### Update Integration
117118

118-
Updates the New Relic log ingestion function to the latest version.
119+
Updates the New Relic log ingestion function to the latest version. Existing ingestion function parameters will
120+
retain their values, unless you specify different values on the command line.
119121

120122
```bash
121-
newrelic-lambda integrations update \
122-
--nr-account-id <account id> \
123-
--nr-api-key <api key>
123+
newrelic-lambda integrations update
124124
```
125125

126126
| Option | Required? | Description |
127127
|--------|-----------|-------------|
128-
| `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) for the integration. Only required if also uninstalling the New Relic AWS Lambda integration. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
129-
| `--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. |
130-
| `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. This is disabled by default. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |
131-
| `--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. |
132-
| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
128+
| `--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 changing the account to which the logs are sent. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
129+
| `--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 required if changing the account to which the logs are sent. |
130+
| `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |
131+
| `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
132+
| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. |
133133
| `--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`. |
134-
| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
134+
| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. |
135+
| `--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. |
135136
| `--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. |
136137
| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
137138

newrelic_lambda_cli/cli/integrations.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def register(group):
5858
show_default=True,
5959
type=click.INT,
6060
)
61+
@click.option(
62+
"--role-name",
63+
help="The name of a pre-created execution role for the log ingest function",
64+
metavar="<role_name>",
65+
show_default=False,
66+
)
6167
def install(
6268
aws_profile,
6369
aws_region,
@@ -70,6 +76,7 @@ def install(
7076
nr_api_key,
7177
nr_region,
7278
timeout,
79+
role_name,
7380
):
7481
"""Install New Relic AWS Lambda Integration"""
7582
session = boto3.Session(profile_name=aws_profile, region_name=aws_region)
@@ -106,7 +113,7 @@ def install(
106113

107114
click.echo("Creating newrelic-log-ingestion Lambda function in AWS account")
108115
res = integrations.install_log_ingestion(
109-
session, nr_license_key, enable_logs, memory_size, timeout
116+
session, nr_license_key, enable_logs, memory_size, timeout, role_name
110117
)
111118
install_success = res and install_success
112119

@@ -163,57 +170,48 @@ def uninstall(aws_profile, aws_region, aws_permissions_check, nr_account_id, for
163170
@add_options(AWS_OPTIONS)
164171
@click.option(
165172
"--enable-logs/--disable-logs",
166-
default=False,
173+
default=None,
167174
help="Determines if logs are forwarded to New Relic Logging",
168-
show_default=True,
169175
)
170176
@click.option(
171177
"--memory-size",
172178
"-m",
173-
default=128,
174179
help="Memory size (in MiB) for the log ingestion function",
175180
metavar="<size>",
176-
show_default=True,
177181
type=click.INT,
178182
)
179-
@add_options(NR_OPTIONS)
180183
@click.option(
181184
"--timeout",
182185
"-t",
183-
default=30,
184186
help="Timeout (in seconds) for the New Relic log ingestion function",
185187
metavar="<secs>",
186-
show_default=True,
187188
type=click.INT,
188189
)
190+
@click.option(
191+
"--role-name",
192+
help="The name of a new pre-created execution role for the log ingest function",
193+
metavar="<role_name>",
194+
)
189195
def update(
190196
aws_profile,
191197
aws_region,
192198
aws_permissions_check,
193199
enable_logs,
194200
memory_size,
195-
nr_account_id,
196-
nr_api_key,
197-
nr_region,
198201
timeout,
202+
role_name,
199203
):
200204
"""UpdateNew Relic AWS Lambda Integration"""
201205
session = boto3.Session(profile_name=aws_profile, region_name=aws_region)
202206

203207
if aws_permissions_check:
204208
permissions.ensure_integration_install_permissions(session)
205209

206-
click.echo("Validating New Relic credentials")
207-
gql_client = api.validate_gql_credentials(nr_account_id, nr_api_key, nr_region)
208-
209-
click.echo("Retrieving integration license key")
210-
nr_license_key = api.retrieve_license_key(gql_client)
211-
212210
update_success = True
213211

214212
click.echo("Updating newrelic-log-ingestion Lambda function in AWS account")
215213
res = integrations.update_log_ingestion(
216-
session, nr_license_key, enable_logs, memory_size, timeout
214+
session, None, enable_logs, memory_size, timeout, role_name
217215
)
218216
update_success = res and update_success
219217

0 commit comments

Comments
 (0)