<a id="cli-aws-amplifygen3-logs-config-edit"></a>

# edit

## Description

Change the log sampling settings of an environment: the percentage of requests recorded in access logs and firewall (AWS WAF) logs, set separately for CloudWatch Logs and Amazon S3, and which requests the firewall logs record. It also sets the sampling rates of the backend’s database (Postgres) logs for CloudWatch Logs and Amazon S3. For every log type, a rate of 0 turns that delivery off. Settings you do not pass are kept, except that the CloudWatch access-log rate is set to 5 if the environment has none yet.

Logs delivered to Amazon S3 need a bucket: name your own with –access-log-s3-bucket, –firewall-log-s3-bucket or –database-log-s3-bucket, or pass –managed-bucket to use the app’s managed bucket for each log type: the one its other environments deliver to, or a new one when none has it yet. Once an environment has a bucket, it is kept until you name another.

With no flags, the command shows the current settings and lets you pick which to change; in CI (CI=true), where it cannot prompt, it fails instead. To change other environment settings, use `aws amplifygen3 env edit`.

## Synopsis

```
  edit
[--env <value>]
[--access-log-cwl-sampling-rate <value>]
[--access-log-s3-sampling-rate <value>]
[--firewall-log-cwl-sampling-rate <value>]
[--firewall-log-s3-sampling-rate <value>]
[--firewall-log-scope <value>]
[--database-log-cwl-sampling-rate <value>]
[--database-log-s3-sampling-rate <value>]
[--access-log-s3-bucket <value>]
[--firewall-log-s3-bucket <value>]
[--database-log-s3-bucket <value>]
[--managed-bucket]
[--app <value>]
[--config <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
[--cli-error-format <value>]
[--help]
```

## Options

`--env` (string)
Environment to change. Defaults to preview. Shorthand: -e.

`--access-log-cwl-sampling-rate` (string)
Percentage of requests (0 to 100) recorded in the access logs sent to CloudWatch Logs. 0 turns these logs off. If omitted and the environment has no rate yet, 5 is used.

`--access-log-s3-sampling-rate` (string)
Percentage of requests (0 to 100) recorded in the access logs sent to Amazon S3. 0 turns these logs off.

`--firewall-log-cwl-sampling-rate` (string)
Percentage of requests (0 to 100) recorded in the firewall (AWS WAF) logs sent to CloudWatch Logs. 0 turns these logs off.

`--firewall-log-s3-sampling-rate` (string)
Percentage of requests (0 to 100) recorded in the firewall (AWS WAF) logs sent to Amazon S3. 0 turns these logs off.

`--firewall-log-scope` (string)
Which requests the firewall logs record: ‘all-requests’ or ‘blocked-only’. The environment must have a firewall log sampling rate, set in this command or earlier.

> * `all-requests`
> * `blocked-only`

`--database-log-cwl-sampling-rate` (string)
Percentage of the backend’s database (Postgres) log lines (0 to 100) delivered to CloudWatch Logs. 0 turns these logs off. Database log delivery is available only in some AWS Regions; where it is not available, the service rejects the change and explains why.

`--database-log-s3-sampling-rate` (string)
Percentage of the backend’s database (Postgres) log lines (0 to 100) delivered to Amazon S3. 0 turns these logs off. Database log delivery is available only in some AWS Regions; where it is not available, the service rejects the change and explains why.

`--access-log-s3-bucket` (string)
Amazon S3 bucket the access logs are delivered to, as a bucket name or an ARN (arn:aws:s3:::my-bucket). Pass it together with –access-log-s3-sampling-rate with a rate above 0, or with another change that keeps S3 delivery of these logs on. If omitted, the bucket the environment already uses is kept; an environment with none needs this flag or –managed-bucket. The bucket policy must let CloudWatch Logs (delivery.logs.amazonaws.com) write to the bucket.

`--firewall-log-s3-bucket` (string)
Amazon S3 bucket the firewall (AWS WAF) logs are delivered to, as a bucket name or an ARN (arn:aws:s3:::my-bucket). Pass it together with –firewall-log-s3-sampling-rate with a rate above 0, or with another change that keeps S3 delivery of these logs on. If omitted, the bucket the environment already uses is kept; an environment with none needs this flag or –managed-bucket. The bucket policy must let CloudWatch Logs (delivery.logs.amazonaws.com) write to the bucket.

`--database-log-s3-bucket` (string)
Amazon S3 bucket the database (Postgres) logs are delivered to, as a bucket name or an ARN (arn:aws:s3:::my-bucket). Pass it together with –database-log-s3-sampling-rate with a rate above 0, or with another change that keeps S3 delivery of these logs on. If omitted, the bucket the environment already uses is kept; an environment with none needs this flag or –managed-bucket. The bucket policy must let CloudWatch Logs (delivery.logs.amazonaws.com) write to the bucket.

`--managed-bucket` (boolean)
Deliver each log type this command sends to Amazon S3 without a bucket flag to the app’s managed bucket for that log type. There is one per log type, shared by the app’s environments: when another environment of the app already delivers these logs to its managed bucket, that bucket is reused. Otherwise the command creates one in your account regional namespace, where only your account can create buckets, named ag3-<type>-logs-<app>-<account>-<region>-an (for example ag3-firewall-logs-my-app-111122223333-us-east-1-an). When the app name does not fit the 63 characters of a bucket name, it is shortened and followed by an 8-character hash of the full app name. A new bucket blocks public access, uses SSE-S3 encryption, and lets only CloudWatch Logs deliveries from your account write to it.

`--app` (string)
App name. If omitted, the name is read from the config file (amplify.jsonc by default, see –config), then package.json in the current directory, then the current directory name. Shorthand: -a.

`--config` (string)
Path to the configuration file to read the app name from when –app is not passed. Defaults to amplify.jsonc in the current directory. Shorthand: -c.

## Global Options

`--debug` (boolean)

Turn on debug logging.

`--endpoint-url` (string)

Override command’s default URL with the given URL.

`--no-verify-ssl` (boolean)

By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.

`--no-paginate` (boolean)

Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.

`--output` (string)

The formatting style for command output.

* json
* text
* table
* yaml
* yaml-stream
* off

`--query` (string)

A JMESPath query to use in filtering the response data.

`--profile` (string)

Use a specific profile from your credential file.

`--region` (string)

The region to use. Overrides config/env settings.

`--version` (string)

Display the version of this tool.

`--color` (string)

Turn on/off color output.

* on
* off
* auto

`--no-sign-request` (boolean)

Do not sign requests. Credentials will not be loaded if this argument is provided.

`--ca-bundle` (string)

The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.

`--cli-read-timeout` (int)

The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.

`--cli-connect-timeout` (int)

The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.

`--cli-binary-format` (string)

The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob `fileb://` will always be treated as binary and use the file contents directly regardless of the `cli-binary-format` setting. When using `file://` the file contents will need to properly formatted for the configured `cli-binary-format`.

* base64
* raw-in-base64-out

`--no-cli-pager` (boolean)

Disable cli pager for output.

`--cli-auto-prompt` (boolean)

Automatically prompt for CLI input parameters.

`--no-cli-auto-prompt` (boolean)

Disable automatically prompt for CLI input parameters.

`--cli-error-format` (string)

The formatting style for error output. By default, errors are displayed in enhanced format.

* legacy
* json
* yaml
* text
* table
* enhanced

`--help` (boolean)

Display help for the command/subcommand.

## Examples

#### NOTE
To use the following examples, you must have the AWS CLI installed and configured. See the [Getting started guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) in the *AWS CLI User Guide* for more information.

Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal’s quoting rules. See [Using quotation marks with strings](https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-quoting-strings.html) in the *AWS CLI User Guide* .

**Example 1: To record a percentage of requests in access logs**

The following `logs-config edit` example records 25 percent of requests in
CloudWatch Logs access logs. Settings you do not pass are kept.

```bash
aws amplifygen3 logs-config edit \
    --app my-app \
    --env production \
    --access-log-cwl-sampling-rate 25
```

Output:

```
Updated environment 'production' in app 'my-app'
  - access-log-cwl-sampling-rate: 25
```

**Example 2: To log only requests the firewall blocked**

The following `logs-config edit` example records every firewall (AWS WAF)
decision in CloudWatch Logs but narrows the records to blocked requests, which
is the usual setting for investigating traffic without paying to log all of
it.

```bash
aws amplifygen3 logs-config edit \
    --app my-app \
    --env production \
    --firewall-log-cwl-sampling-rate 100 \
    --firewall-log-scope blocked-only
```

Output:

```
Updated environment 'production' in app 'my-app'
  - firewall-log-cwl-sampling-rate: 100
  - firewall-log-scope:             blocked-only
```

**Example 3: To deliver firewall logs to a bucket created for you**

The following `logs-config edit` example delivers every firewall (AWS WAF)
decision to Amazon S3. `--managed-bucket` uses the app’s managed bucket for
the firewall logs: the one another environment of the app already delivers its
firewall logs to, or a new one named
`ag3-firewall-logs-<app>-<account>-<region>-an`. The bucket is in your
account regional namespace, where only your account can create buckets. An app
name too long for the 63 characters of a bucket name is shortened and followed
by an 8-character hash of the full name. A new bucket blocks public access and
lets only CloudWatch Logs deliveries from your account write to it.

```bash
aws amplifygen3 logs-config edit \
    --app my-app \
    --env production \
    --firewall-log-s3-sampling-rate 100 \
    --managed-bucket
```

Output:

```
Updated environment 'production' in app 'my-app'
  - firewall-log-s3-sampling-rate: 100
  - firewall-log-s3-bucket:        arn:aws:s3:::ag3-firewall-logs-my-app-123456789012-us-west-2-an (new managed bucket)
```

**Example 4: To deliver database logs to your own bucket**

The following `logs-config edit` example delivers every line of the
backend’s database logs to a bucket you own. Pass either the bucket’s name or
its ARN. The bucket policy must let CloudWatch Logs
(`delivery.logs.amazonaws.com`) write to it. Later edits keep the bucket
until you name another. To turn this delivery off, pass
`--database-log-s3-sampling-rate 0`.

```bash
aws amplifygen3 logs-config edit \
    --app my-app \
    --env production \
    --database-log-s3-sampling-rate 100 \
    --database-log-s3-bucket amzn-s3-demo-bucket
```

Output:

```
Updated environment 'production' in app 'my-app'
  - database-log-s3-sampling-rate: 100
  - database-log-s3-bucket:        arn:aws:s3:::amzn-s3-demo-bucket
```

Note that if the environment has no CloudWatch access-log rate yet, editing
sets it to 5. To see the current settings without changing them, use
`aws amplifygen3 logs-config get`.
