> ## Documentation Index
> Fetch the complete documentation index at: https://kosli-docs-snapshot-deployment-diffs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# kosli snapshot s3

> Report a snapshot of the content of an AWS S3 bucket to Kosli.

## Synopsis

```shell theme={null}
kosli snapshot s3 ENVIRONMENT-NAME [flags]
```

Report a snapshot of the content of an AWS S3 bucket to Kosli.

To authenticate to AWS, you can either:

1. provide the AWS static credentials via flags or by exporting the equivalent KOSLI env vars (e.g. KOSLI\_AWS\_KEY\_ID)
2. export the AWS env vars (e.g. AWS\_ACCESS\_KEY\_ID).
3. Use a shared config/credentials file under the \$HOME/.aws

Option 1 takes highest precedence, while option 3 is the lowest.
More details can be found here: [https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials)

You can report the entire bucket content, or filter some of the content using `--include` / `--exclude` (literal prefix match) or `--include-regex` / `--exclude-regex` (Go regular expressions matched against the full object key).
In all cases, the content is reported as one artifact. If you wish to report separate files/dirs within the same bucket as separate artifacts, you need to run the command twice.
Object keys that cannot be stored as a local file, such as keys containing a `..` path segment, are rejected and fail the snapshot, naming the key. Two keys that resolve to the same local file are also an error. A legitimate key of that shape can be left out with `--exclude-regex` (anchor and escape it, since the pattern is a regular expression matched against the whole key); when `--include` or `--include-regex` is set, exclude filters are ignored, so narrow the include filter instead.

To specify paths in a directory artifact that should always be excluded from the SHA256 calculation, you can add a `.kosli_ignore` file to the root of the artifact.
Each line should specify a relative path or path glob to be ignored. You can include comments in this file, using `#`.
The `.kosli_ignore` file is always treated as part of the artifact: its own entries cannot exclude it, so the exclusion list cannot be changed without changing the fingerprint.
Paths the list already matches stay excluded whatever is later added there, so keep its entries as narrow as possible.

## Flags

| Flag               | Type    | Description                                                                                                                                                                                                        |
| :----------------- | :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--aws-key-id`     | string  | The AWS access key ID.                                                                                                                                                                                             |
| `--aws-region`     | string  | The AWS region.                                                                                                                                                                                                    |
| `--aws-secret-key` | string  | The AWS secret access key.                                                                                                                                                                                         |
| `--bucket`         | string  | The name of the S3 bucket.                                                                                                                                                                                         |
| `-D`, `--dry-run`  | bool    | \[optional] Run in dry-run mode. When enabled, no data is sent to Kosli and the CLI exits with 0 exit code regardless of any errors.                                                                               |
| `-x`, `--exclude`  | strings | \[optional] The comma separated list of file and/or directory paths in the S3 bucket to exclude when fingerprinting. Paths match by literal prefix. Cannot be used together with `--include` or `--include-regex`. |
| `--exclude-regex`  | strings | \[optional] The comma separated list of Go regular expressions matched against object keys in the S3 bucket to exclude when fingerprinting. Cannot be used together with `--include` or `--include-regex`.         |
| `-h`, `--help`     | bool    | help for s3                                                                                                                                                                                                        |
| `-i`, `--include`  | strings | \[optional] The comma separated list of file and/or directory paths in the S3 bucket to include when fingerprinting. Paths match by literal prefix. Cannot be used together with `--exclude` or `--exclude-regex`. |
| `--include-regex`  | strings | \[optional] The comma separated list of Go regular expressions matched against object keys in the S3 bucket to include when fingerprinting. Cannot be used together with `--exclude` or `--exclude-regex`.         |

## Flags inherited from parent commands

| Flag                        | Type   | Description                                                                                                                                                                                                                                              |
| :-------------------------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-a`, `--api-token`         | string | The Kosli API token.                                                                                                                                                                                                                                     |
| `-A`, `--auto-environment`  | bool   | \[optional] Create the environment (with the type inferred from the snapshot subcommand) if it does not already exist, before reporting the snapshot.                                                                                                    |
| `-c`, `--config-file`       | string | \[optional] The Kosli config file path. Config is read from this path or the default only, never implicitly from the current directory. (default "\$HOME/.kosli.yml")                                                                                    |
| `--debug`                   | bool   | \[optional] Print debug logs to stdout.                                                                                                                                                                                                                  |
| `--environment-description` | string | \[optional] The environment description.                                                                                                                                                                                                                 |
| `--exclude-scaling`         | bool   | \[optional] Exclude scaling events for snapshots. Snapshots with scaling changes will not result in new environment records. (DEPRECATED: this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots.) |
| `-H`, `--host`              | string | \[defaulted] The Kosli endpoint. (default "[https://app.kosli.com](https://app.kosli.com)")                                                                                                                                                              |
| `--http-proxy`              | string | \[optional] The HTTP proxy URL including protocol and port number. e.g. `http://proxy-server-ip:proxy-port`                                                                                                                                              |
| `--include-scaling`         | bool   | \[optional] Include scaling events for snapshots. Snapshots with scaling changes will result in new environment records. (DEPRECATED: this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots.)     |
| `-r`, `--max-api-retries`   | int    | \[defaulted] How many times should API calls be retried when the API host is not reachable. (default 3)                                                                                                                                                  |
| `--org`                     | string | The Kosli organization.                                                                                                                                                                                                                                  |
| `-q`, `--quiet`             | bool   | \[optional] Suppress non-critical warning messages. Errors and normal output are not affected. If both `--quiet` and `--debug` are set, `--debug` wins.                                                                                                  |

## Examples Use Cases

These examples all assume that the flags  `--api-token`, `--org`, `--host`, (and `--flow`, `--trail` when required), are [set/provided](/getting_started/install/#assigning-flags-via-environment-variables).

<AccordionGroup>
  <Accordion title="report the contents of an entire AWS S3 bucket (AWS auth provided in env variables)">
    ```shell theme={null}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot s3 yourEnvironmentName 
    	--bucket yourBucketName 

    ```
  </Accordion>

  <Accordion title="report what is running in an AWS S3 bucket (AWS auth provided in flags)">
    ```shell theme={null}
    kosli snapshot s3 yourEnvironmentName 
    	--bucket yourBucketName 
    	--aws-key-id yourAWSAccessKeyID 
    	--aws-secret-key yourAWSSecretAccessKey 
    	--aws-region yourAWSRegion 

    ```
  </Accordion>

  <Accordion title="report a subset of contents of an AWS S3 bucket (AWS auth provided in env variables)">
    ```shell theme={null}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot s3 yourEnvironmentName 
    	--bucket yourBucketName 
    	--include file.txt,path/within/bucket 

    ```
  </Accordion>

  <Accordion title="report contents of an entire AWS S3 bucket, except for some paths (AWS auth provided in env variables)">
    ```shell theme={null}
    export AWS_REGION=yourAWSRegion
    export AWS_ACCESS_KEY_ID=yourAWSAccessKeyID
    export AWS_SECRET_ACCESS_KEY=yourAWSSecretAccessKey

    kosli snapshot s3 yourEnvironmentName 
    	--bucket yourBucketName 
    	--exclude file.txt,path/within/bucket 

    ```
  </Accordion>

  <Accordion title="report contents of an AWS S3 bucket, excluding all PNG files via a regex">
    ```shell theme={null}
    kosli snapshot s3 yourEnvironmentName 
    	--bucket yourBucketName 
    	--exclude-regex '.*\.png$' 
    ```
  </Accordion>
</AccordionGroup>
