newrelic-lambda-cli


Namenewrelic-lambda-cli JSON
Version 0.9.1 PyPI version JSON
download
home_pagehttps://github.com/newrelic/newrelic-lambda-cli
SummaryA CLI to install the New Relic AWS Lambda integration and layers.
upload_time2024-05-07 07:50:31
maintainerNone
docs_urlNone
authorNew Relic
requires_python>=3.3
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Community Plus header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Plus.png)](https://opensource.newrelic.com/oss-category/#community-plus)

# newrelic-lambda-cli [![Build Status](https://circleci.com/gh/newrelic/newrelic-lambda-cli.svg?style=svg)](https://circleci.com/gh/newrelic/newrelic-lambda-cli) [![Coverage](https://codecov.io/gh/newrelic/newrelic-lambda-cli/branch/master/graph/badge.svg?token=1Rl7h0O1JJ)](https://codecov.io/gh/newrelic/newrelic-lambda-cli)

A CLI to install the New Relic AWS Lambda integration and layers.

## Table of Contents

* **[Features](#features)**
* **[Runtimes Supported](#runtimes-supported)**
* **[Requirements](#requirements)**
* **[Recommendations](#recommendations)**
* **[Installation](#installation)**
* **[Usage](#usage)**
    * [AWS Lambda Integration](#aws-lambda-integration)
    * [AWS Lambda Layers](#aws-lambda-layers)
    * [AWS Lambda Functions](#aws-lambda-functions)
    * [NewRelic Log Subscription](#newRelic-log-subscription)
* **[Docker](#docker)**
* **[Contributing](#contributing)**
* **[Code Style](#code-style)**
* **[Running Tests](#running-tests)**
* **[Troubleshooting](#troubleshooting)**

## Features

* Installs the New Relic AWS Lambda integration onto your AWS account
* Installs and configures a New Relic AWS Lambda layer onto your AWS Lambda functions
* Automatically selects the correct New Relic layer for your function's runtime and region
* Wraps your AWS Lambda functions without requiring a code change
* Supports Go, Java, .NET, Node.js, Python, and Ruby AWS Lambda runtimes
* Easily uninstall the AWS Lambda layer with a single command

## Runtimes Supported

* dotnetcore3.1
* java8.al2
* java11
* java17
* java21
* nodejs16.x
* nodejs18.x
* nodejs20.x
* provided
* provided.al2
* python3.7
* python3.8
* python3.9
* python3.10
* python3.11
* python3.12
* ruby3.2
* ruby3.3

**Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,
manual function wrapping is required using the runtime specific New Relic agent.

## Requirements

* Python >= 3.3 <= 3.12
* 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)

## Recommendations

* Install the [AWS CLI](https://github.com/aws/aws-cli) and configure your environment with `aws configure`

## Installation

```bash
pip3 install newrelic-lambda-cli
```

Or clone this repo and run:

```bash
python3 setup.py install
```

To update the CLI, run:

```
pip3 install --upgrade newrelic-lambda-cli
```

## Usage

### AWS Lambda Integration

#### Install Integration

In order to instrument your AWS Lambda functions using New Relic you must first install
the New Relic AWS Lambda integration and the log ingestion function in the AWS region
in which your Lambda functions are located. If you have Lambda functions located in multiple
regions you can run the command multiple times specifying the AWS regions with
`--aws-region <your aws region here>`. This command only needs to be run once per AWS
region. By default this command will look for a default AWS profile configured via the AWS CLI.

```bash
newrelic-lambda integrations install \
    --nr-account-id <account id> \
    --nr-api-key <api key>
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) for this integration. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
| `--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. |
| `--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>". |
| `--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. |
| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |
| `--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`. |
| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |
| `--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. |
| `--integration-arn` | No | Specify an existing AWS IAM role to use for the New Relic Lambda integration instead of creating one. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
| `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |
| `--disable-license-key-secret` | No | Don't create a managed secret for your account's New Relic License Key |
| `--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`. |
| `--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 |

#### Uninstall Integration

```bash
newrelic-lambda integrations uninstall
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--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. |
| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
| `--force` or `-f` | No | Forces uninstall non-interactively |
| `--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. |
| `--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 |

#### Update Integration

Updates the New Relic log ingestion function to the latest version. Existing ingestion function parameters will
retain their values, unless you specify different values on the command line. By default, installs the license key
secret, if it is missing.

```bash
newrelic-lambda integrations update \
    --nr-account-id <account id> \
    --nr-api-key <api key>
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--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 changing the account to which the logs are sent. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
| `--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. Only required if changing the account to which the logs are sent. |
| `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |
| `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern ""` afterwards. |
| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. |
| `--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`. |
| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. |
| `--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. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
| `--disable-license-key-secret` | No | Disable automatic creation of the license key secret on update. The secret is not created if it exists. |
| `--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`. |
| `--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 |

### AWS Lambda Layers

#### Install Layer

```bash
newrelic-lambda layers install \
    --function <name or arn> \
    --nr-account-id <new relic account id>
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--function` or `-f` | Yes | The AWS Lambda function name or ARN in which to add a layer. Can provide multiple `--function` arguments. Will also accept `all`, `installed` and `not-installed` similar to `newrelic-lambda functions list`. |
| `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) this function should use. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |
| `--exclude` or `-e` | No | A function name to exclude while installing layers. Can provide multiple `--exclude` arguments. Only checked when `all`, `installed` and `not-installed` are used. See `newrelic-lambda functions list` for function names. |
| `--layer-arn` or `-l` | No | Specify a specific layer version ARN to use. This is auto detected by default. |
| `--upgrade` or `-u` | No | Permit upgrade to the latest layer version for this region and runtime. |
| `--disable-extension` | No | Disable the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). |
| `--enable-extension-function-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |
| `--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. |
| `--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. |
| `--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`. |

#### Uninstall Layer

```bash
newrelic-lambda layers uninstall --function <name or arn>
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--function` or `-f` | Yes | The AWS Lambda function name or ARN in which to remove a layer. Can provide multiple `--function` arguments. Will also accept `all`, `installed` and `not-installed` similar to `newrelic-lambda functions list`. |
| `--exclude` or `-e` | No | A function name to exclude while uninstalling layers. Can provide multiple `--exclude` arguments. Only checked when `all`, `installed` and `not-installed` are used. See `newrelic-lambda functions list` for function names. |
| `--layer-arn` or `-l` | No | Specify a specific layer version ARN to remove. This is auto detected by default. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |

### AWS Lambda Functions

#### List Functions

```bash
newrelic-lambda functions list
```

List functions with layer installed:

```bash
newrelic-lambda functions list --filter installed
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--filter` or `-f` | No | Filter to be applied to list of functions. Options are `all`, `installed` and `not-installed`. Defaults to `all`. |
| `--output` or `-o` | No | Specify the desired output format. Supports `table` and `text`. Defaults to `table`. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region to use for this command. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |

### NewRelic Log Subscription

#### Install Log Subscription

```bash
newrelic-lambda subscriptions install --function <name or arn>
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--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`. |
| `--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 |
| `--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. |
| `--filter-pattern` | No | Specify a custom log subscription filter pattern. To collect all logs use `--filter-pattern ""`. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |

#### Uninstall Log Subscription

```bash
newrelic-lambda subscriptions uninstall --function <name or arn>
```

| Option | Required? | Description |
|--------|-----------|-------------|
| `--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`. |
| `--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 |
| `--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. |
| `--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. |
| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |

## Docker

Now, you can run newrelic-lambda-cli as a container.

```bash
docker build -t newrelic-lambda-cli .
docker run -e AWS_PROFILE=your_profile -v $HOME/.aws:/home/newrelic-lambda-cli/.aws newrelic-lambda-cli functions list
```

## Contributing

We welcome code contributions (in the form of pull requests) from our user community. Before submitting a pull request please review [these guidelines](CONTRIBUTING.md).

Following these helps us efficiently review and incorporate your contribution and avoid breaking your code with future changes to the agent.

## Code style

We use the [black](https://github.com/ambv/black) code formatter.

```bash
pip install black
```

We recommend using it with [pre-commit](https://pre-commit.com/#install):

```bash
pip install pre-commit
pre-commit install
```

Using these together will auto format your git commits.

## Running Tests

```bash
python setup.py test
```

## Troubleshooting

**Upgrade the CLI**: A good first step, as we push updates frequently.

```
pip3 install --upgrade newrelic-lambda-cli
```

**UnrecognizedClientException**:
>`(UnrecognizedClientException) when calling the GetFunction operation: The security token included in the request is invalid.`

If you see this error, it means that specifying the region is necessary, and you need to supply the `--aws-region` flag to your command.

**Unable to locate credentials:**
>`Function: None, Region: None, Error: Failed to set up lambda integration: 'Unable to locate credentials. You can configure credentials by running "aws configure".'`

1. The AWS profile may not be properly configured; review documentation to [Configure your AWS Profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) (make sure the default region is set!).
2. If there are multiple AWS profiles and the correct one is not specified, you can run `export AWS_DEFAULT_PROFILE=MY_OTHER_PROFILE` to set the environment variable to the proper profile.

**SimulatePrincipalPolicy**:
>`botocore.errorfactory.InvalidInputException: An error occurred (InvalidInput) when calling the SimulatePrincipalPolicy operation: Invalid Entity Arn: arn:aws:sts::123456789012:assumed-role/u-admin/botocore-session-0987654321 does not clearly define entity type and name.`

Some AWS accounts can have permission to operate on resources without having access to SimulatePrincipalPolicy.
If this is the case, supply the `--no-aws-permissions-check` flag to your command.

**Error adding new region to integration**:
>`Linking New Relic account to AWS account
Traceback (most recent call last):
  ...
  File "/Users/USER/PYTHONPATH/lib/python3.8/site-packages/newrelic_lambda_cli/gql.py", line 131, in link_account
    return res["cloudLinkAccount"]["linkedAccounts"][0]
IndexError: list index out of range`

This error can happen if you have an existing AWS integration, and are running `newrelic-lambda integrations install` with a different `--linked-account-name` (for instance, to add a new region to the integration). The linked account name can be whatever you want it to be, but needs to be consistent with the previously linked AWS account.

**AWS Secrets Manager Secret Name Conflict**
This CLI manages a AWS Secrets Manager secret with the name `NEW_RELIC_LICENSE_KEY`. If
you run into a CloudFormation error reporting that this secret already exists, make
sure that you delete any existing secrets and try again. Keep in mind, by default in the
AWS console when you delete a secret from AWS Secrets Manager that it will not delete
the secret permanently for several days. You will need to perform a "force delete without
recovery" when deleting the secret to avoid this naming conflict.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/newrelic/newrelic-lambda-cli",
    "name": "newrelic-lambda-cli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.3",
    "maintainer_email": null,
    "keywords": null,
    "author": "New Relic",
    "author_email": "serverless-dev@newrelic.com",
    "download_url": "https://files.pythonhosted.org/packages/10/20/a53e8725f5ed72ed499cf7431f08326492ba5f24d3d51b2736e8b0a5658f/newrelic_lambda_cli-0.9.1.tar.gz",
    "platform": null,
    "description": "[![Community Plus header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Plus.png)](https://opensource.newrelic.com/oss-category/#community-plus)\n\n# newrelic-lambda-cli [![Build Status](https://circleci.com/gh/newrelic/newrelic-lambda-cli.svg?style=svg)](https://circleci.com/gh/newrelic/newrelic-lambda-cli) [![Coverage](https://codecov.io/gh/newrelic/newrelic-lambda-cli/branch/master/graph/badge.svg?token=1Rl7h0O1JJ)](https://codecov.io/gh/newrelic/newrelic-lambda-cli)\n\nA CLI to install the New Relic AWS Lambda integration and layers.\n\n## Table of Contents\n\n* **[Features](#features)**\n* **[Runtimes Supported](#runtimes-supported)**\n* **[Requirements](#requirements)**\n* **[Recommendations](#recommendations)**\n* **[Installation](#installation)**\n* **[Usage](#usage)**\n    * [AWS Lambda Integration](#aws-lambda-integration)\n    * [AWS Lambda Layers](#aws-lambda-layers)\n    * [AWS Lambda Functions](#aws-lambda-functions)\n    * [NewRelic Log Subscription](#newRelic-log-subscription)\n* **[Docker](#docker)**\n* **[Contributing](#contributing)**\n* **[Code Style](#code-style)**\n* **[Running Tests](#running-tests)**\n* **[Troubleshooting](#troubleshooting)**\n\n## Features\n\n* Installs the New Relic AWS Lambda integration onto your AWS account\n* Installs and configures a New Relic AWS Lambda layer onto your AWS Lambda functions\n* Automatically selects the correct New Relic layer for your function's runtime and region\n* Wraps your AWS Lambda functions without requiring a code change\n* Supports Go, Java, .NET, Node.js, Python, and Ruby AWS Lambda runtimes\n* Easily uninstall the AWS Lambda layer with a single command\n\n## Runtimes Supported\n\n* dotnetcore3.1\n* java8.al2\n* java11\n* java17\n* java21\n* nodejs16.x\n* nodejs18.x\n* nodejs20.x\n* provided\n* provided.al2\n* python3.7\n* python3.8\n* python3.9\n* python3.10\n* python3.11\n* python3.12\n* ruby3.2\n* ruby3.3\n\n**Note:** Automatic handler wrapping is only supported for Node.js, Python, Java, and Ruby. For other runtimes,\nmanual function wrapping is required using the runtime specific New Relic agent.\n\n## Requirements\n\n* Python >= 3.3 <= 3.12\n* 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)\n\n## Recommendations\n\n* Install the [AWS CLI](https://github.com/aws/aws-cli) and configure your environment with `aws configure`\n\n## Installation\n\n```bash\npip3 install newrelic-lambda-cli\n```\n\nOr clone this repo and run:\n\n```bash\npython3 setup.py install\n```\n\nTo update the CLI, run:\n\n```\npip3 install --upgrade newrelic-lambda-cli\n```\n\n## Usage\n\n### AWS Lambda Integration\n\n#### Install Integration\n\nIn order to instrument your AWS Lambda functions using New Relic you must first install\nthe New Relic AWS Lambda integration and the log ingestion function in the AWS region\nin which your Lambda functions are located. If you have Lambda functions located in multiple\nregions you can run the command multiple times specifying the AWS regions with\n`--aws-region <your aws region here>`. This command only needs to be run once per AWS\nregion. By default this command will look for a default AWS profile configured via the AWS CLI.\n\n```bash\nnewrelic-lambda integrations install \\\n    --nr-account-id <account id> \\\n    --nr-api-key <api key>\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) for this integration. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |\n| `--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. |\n| `--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>\". |\n| `--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. |\n| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. Default to 128MB. |\n| `--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`. |\n| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. Defaults to 30 seconds. |\n| `--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. |\n| `--integration-arn` | No | Specify an existing AWS IAM role to use for the New Relic Lambda integration instead of creating one. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n| `--aws-role-policy` | No | Specify an alternative IAM role policy ARN for this integration. |\n| `--disable-license-key-secret` | No | Don't create a managed secret for your account's New Relic License Key |\n| `--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`. |\n| `--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 |\n\n#### Uninstall Integration\n\n```bash\nnewrelic-lambda integrations uninstall\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n| `--force` or `-f` | No | Forces uninstall non-interactively |\n| `--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. |\n| `--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 |\n\n#### Update Integration\n\nUpdates the New Relic log ingestion function to the latest version. Existing ingestion function parameters will\nretain their values, unless you specify different values on the command line. By default, installs the license key\nsecret, if it is missing.\n\n```bash\nnewrelic-lambda integrations update \\\n    --nr-account-id <account id> \\\n    --nr-api-key <api key>\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--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 changing the account to which the logs are sent. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |\n| `--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. Only required if changing the account to which the logs are sent. |\n| `--disable-logs` or `-d` | No | Disables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ...` afterwards. |\n| `--enable-logs` or `-e` | No | Enables forwarding logs to New Relic Logging. Make sure you run `newrelic-lambda subscriptions install --function ... --filter-pattern \"\"` afterwards. |\n| `--memory-size` or `-m` | No | Memory size (in MiB) for the New Relic log ingestion function. |\n| `--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`. |\n| `--timeout` or `-t` | No | Timeout (in seconds) for the New Relic log ingestion function. |\n| `--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. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region for the integration. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n| `--disable-license-key-secret` | No | Disable automatic creation of the license key secret on update. The secret is not created if it exists. |\n| `--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`. |\n| `--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 |\n\n### AWS Lambda Layers\n\n#### Install Layer\n\n```bash\nnewrelic-lambda layers install \\\n    --function <name or arn> \\\n    --nr-account-id <new relic account id>\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--function` or `-f` | Yes | The AWS Lambda function name or ARN in which to add a layer. Can provide multiple `--function` arguments. Will also accept `all`, `installed` and `not-installed` similar to `newrelic-lambda functions list`. |\n| `--nr-account-id` or `-a` | Yes | The [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) this function should use. Can also use the `NEW_RELIC_ACCOUNT_ID` environment variable. |\n| `--exclude` or `-e` | No | A function name to exclude while installing layers. Can provide multiple `--exclude` arguments. Only checked when `all`, `installed` and `not-installed` are used. See `newrelic-lambda functions list` for function names. |\n| `--layer-arn` or `-l` | No | Specify a specific layer version ARN to use. This is auto detected by default. |\n| `--upgrade` or `-u` | No | Permit upgrade to the latest layer version for this region and runtime. |\n| `--disable-extension` | No | Disable the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). |\n| `--enable-extension-function-logs` | No | Enable forwarding logs via the [New Relic Lambda Extension](https://github.com/newrelic/newrelic-lambda-extension). Disabled by default. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n| `--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. |\n| `--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. |\n| `--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`. |\n\n#### Uninstall Layer\n\n```bash\nnewrelic-lambda layers uninstall --function <name or arn>\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--function` or `-f` | Yes | The AWS Lambda function name or ARN in which to remove a layer. Can provide multiple `--function` arguments. Will also accept `all`, `installed` and `not-installed` similar to `newrelic-lambda functions list`. |\n| `--exclude` or `-e` | No | A function name to exclude while uninstalling layers. Can provide multiple `--exclude` arguments. Only checked when `all`, `installed` and `not-installed` are used. See `newrelic-lambda functions list` for function names. |\n| `--layer-arn` or `-l` | No | Specify a specific layer version ARN to remove. This is auto detected by default. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n\n### AWS Lambda Functions\n\n#### List Functions\n\n```bash\nnewrelic-lambda functions list\n```\n\nList functions with layer installed:\n\n```bash\nnewrelic-lambda functions list --filter installed\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--filter` or `-f` | No | Filter to be applied to list of functions. Options are `all`, `installed` and `not-installed`. Defaults to `all`. |\n| `--output` or `-o` | No | Specify the desired output format. Supports `table` and `text`. Defaults to `table`. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region to use for this command. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n\n### NewRelic Log Subscription\n\n#### Install Log Subscription\n\n```bash\nnewrelic-lambda subscriptions install --function <name or arn>\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--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`. |\n| `--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 |\n| `--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. |\n| `--filter-pattern` | No | Specify a custom log subscription filter pattern. To collect all logs use `--filter-pattern \"\"`. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n\n#### Uninstall Log Subscription\n\n```bash\nnewrelic-lambda subscriptions uninstall --function <name or arn>\n```\n\n| Option | Required? | Description |\n|--------|-----------|-------------|\n| `--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`. |\n| `--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 |\n| `--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. |\n| `--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. |\n| `--aws-region` or `-r` | No | The AWS region this function is located. Can use `AWS_DEFAULT_REGION` environment variable. Defaults to AWS session region. |\n\n## Docker\n\nNow, you can run newrelic-lambda-cli as a container.\n\n```bash\ndocker build -t newrelic-lambda-cli .\ndocker run -e AWS_PROFILE=your_profile -v $HOME/.aws:/home/newrelic-lambda-cli/.aws newrelic-lambda-cli functions list\n```\n\n## Contributing\n\nWe welcome code contributions (in the form of pull requests) from our user community. Before submitting a pull request please review [these guidelines](CONTRIBUTING.md).\n\nFollowing these helps us efficiently review and incorporate your contribution and avoid breaking your code with future changes to the agent.\n\n## Code style\n\nWe use the [black](https://github.com/ambv/black) code formatter.\n\n```bash\npip install black\n```\n\nWe recommend using it with [pre-commit](https://pre-commit.com/#install):\n\n```bash\npip install pre-commit\npre-commit install\n```\n\nUsing these together will auto format your git commits.\n\n## Running Tests\n\n```bash\npython setup.py test\n```\n\n## Troubleshooting\n\n**Upgrade the CLI**: A good first step, as we push updates frequently.\n\n```\npip3 install --upgrade newrelic-lambda-cli\n```\n\n**UnrecognizedClientException**:\n>`(UnrecognizedClientException) when calling the GetFunction operation: The security token included in the request is invalid.`\n\nIf you see this error, it means that specifying the region is necessary, and you need to supply the `--aws-region` flag to your command.\n\n**Unable to locate credentials:**\n>`Function: None, Region: None, Error: Failed to set up lambda integration: 'Unable to locate credentials. You can configure credentials by running \"aws configure\".'`\n\n1. The AWS profile may not be properly configured; review documentation to [Configure your AWS Profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) (make sure the default region is set!).\n2. If there are multiple AWS profiles and the correct one is not specified, you can run `export AWS_DEFAULT_PROFILE=MY_OTHER_PROFILE` to set the environment variable to the proper profile.\n\n**SimulatePrincipalPolicy**:\n>`botocore.errorfactory.InvalidInputException: An error occurred (InvalidInput) when calling the SimulatePrincipalPolicy operation: Invalid Entity Arn: arn:aws:sts::123456789012:assumed-role/u-admin/botocore-session-0987654321 does not clearly define entity type and name.`\n\nSome AWS accounts can have permission to operate on resources without having access to SimulatePrincipalPolicy.\nIf this is the case, supply the `--no-aws-permissions-check` flag to your command.\n\n**Error adding new region to integration**:\n>`Linking New Relic account to AWS account\nTraceback (most recent call last):\n  ...\n  File \"/Users/USER/PYTHONPATH/lib/python3.8/site-packages/newrelic_lambda_cli/gql.py\", line 131, in link_account\n    return res[\"cloudLinkAccount\"][\"linkedAccounts\"][0]\nIndexError: list index out of range`\n\nThis error can happen if you have an existing AWS integration, and are running `newrelic-lambda integrations install` with a different `--linked-account-name` (for instance, to add a new region to the integration). The linked account name can be whatever you want it to be, but needs to be consistent with the previously linked AWS account.\n\n**AWS Secrets Manager Secret Name Conflict**\nThis CLI manages a AWS Secrets Manager secret with the name `NEW_RELIC_LICENSE_KEY`. If\nyou run into a CloudFormation error reporting that this secret already exists, make\nsure that you delete any existing secrets and try again. Keep in mind, by default in the\nAWS console when you delete a secret from AWS Secrets Manager that it will not delete\nthe secret permanently for several days. You will need to perform a \"force delete without\nrecovery\" when deleting the secret to avoid this naming conflict.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A CLI to install the New Relic AWS Lambda integration and layers.",
    "version": "0.9.1",
    "project_urls": {
        "Homepage": "https://github.com/newrelic/newrelic-lambda-cli"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71966c7edb236677ecc70f28ce3c5d9c987cb6d04953e1447c78e2860196966f",
                "md5": "1281227ab34571a7cfaee7aa018c1ff3",
                "sha256": "9706e5110aa6fb35e14e448ea41bb7815de8b3c585fb4625b5fa61ed22ac18e4"
            },
            "downloads": -1,
            "filename": "newrelic_lambda_cli-0.9.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1281227ab34571a7cfaee7aa018c1ff3",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.3",
            "size": 42256,
            "upload_time": "2024-05-07T07:50:29",
            "upload_time_iso_8601": "2024-05-07T07:50:29.772789Z",
            "url": "https://files.pythonhosted.org/packages/71/96/6c7edb236677ecc70f28ce3c5d9c987cb6d04953e1447c78e2860196966f/newrelic_lambda_cli-0.9.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1020a53e8725f5ed72ed499cf7431f08326492ba5f24d3d51b2736e8b0a5658f",
                "md5": "c8f3e651b418bc4ee472ec5564f59b7f",
                "sha256": "cc7040c92959d91352108e3d58e3cee85efcfdfc597a75f11c6533da5b749eb2"
            },
            "downloads": -1,
            "filename": "newrelic_lambda_cli-0.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c8f3e651b418bc4ee472ec5564f59b7f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.3",
            "size": 50246,
            "upload_time": "2024-05-07T07:50:31",
            "upload_time_iso_8601": "2024-05-07T07:50:31.955018Z",
            "url": "https://files.pythonhosted.org/packages/10/20/a53e8725f5ed72ed499cf7431f08326492ba5f24d3d51b2736e8b0a5658f/newrelic_lambda_cli-0.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-07 07:50:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "newrelic",
    "github_project": "newrelic-lambda-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "newrelic-lambda-cli"
}
        
Elapsed time: 0.24220s