# amfelt add target

Add a target data platform to the project configuration.

Adds a named target to the project configuration file. The plugin argument
specifies the target plugin name (e.g. postgres). Connection details are
supplied as flags. Use `--force` to overwrite an existing target with the same
name.

A login given with `--user` and `--password` is stored, together with the rest of
the connection, in the control-plane vault under `<environment>`/database/`<project id>`/`<name>`, where the project and its environment are the control-plane project
this host bound the file to when it pulled it, and amfelt.yaml records only that
vault reference. This needs a registered agent that can reach the control plane,
a file pulled onto this host, and `--host`, `--database`, `--user` and `--password`. The
port is stored too: `--port`, or else the plugin's default port (5432 for
postgres), and a plugin with no known default needs `--port`. When the vault does
not take the login, nothing is written. With `--force` an existing vault secret is
overwritten. An agent with no control plane passes `--store-login-in-file` to keep
the login in amfelt.yaml instead; commit refuses to push a file in which a
target holds a login.

A login that the project file holds, such as one an agent older than v4.18.2
wrote there, moves to the vault when add-target is run again for that target
with `--force` and its connection, `--user` and `--password` included. The file then
keeps only the reference.

## Usage

```text
amfelt add-target [name] [plugin] [flags]
```

## Examples

```text
add-target dwh postgres --path pcf/PCF-postgres.yaml --host localhost --port
5436 --database dwh --user dwh --password dwh --sslmode disable
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--database` | `string` | — | name of the database on the target server |
| `--db-path` | `string` | — | absolute path to the target database file (for file-based targets like DuckDB) |
| `--force` | `bool` | `false` | ignore warnings and errors |
| `--host` | `string` | — | hostname or IP address of the target database server; required with `--user` and `--password` unless `--store-login-in-file` is given |
| `--password` | `string` | — | password for the target database connection; stored with the rest of the connection in the control-plane vault, and amfelt.yaml records only the vault reference (see `--store-login-in-file`) |
| `--path` | `string` | `amfelt.yaml` | path of the Amfelt project file |
| `--port` | `string` | — | port number of the target database server; with `--user` and `--password` it is stored in the vault, and when it is omitted the plugin's default port is stored (5432 for postgres) |
| `--secret-ref` | `string` | — | vault reference path for credentials (e.g. development/database/`<project-id>`/my-db); skips inline credentials |
| `--sslmode` | `string` | — | SSL mode for the target database connection (e.g. disable, require) |
| `--store-login-in-file` | `bool` | `false` | keep the `--user` and `--password` login in amfelt.yaml instead of the vault, for an agent with no control plane; the login is then stored in plain text in that file, and commit refuses to push the file while it holds the login |
| `--user` | `string` | — | username for the target database connection; stored with the rest of the connection in the control-plane vault, and amfelt.yaml records only the vault reference (see `--store-login-in-file`) |
{.clidoc-flags-table}

## Global flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--amfelt-dir` | `string` | `.amfelt` | directory for workspace files (such as plugins); does not move agent identity (controlled by AMFELT_DIR) |
| `--config` | `string` | — | directory or filename of the application configuration |
| `-f`, `--format` | `string` | `default` | log format to use; either default, pretty, or json |
| `-l`, `--level` | `string` | `info` | minimum log level to display; either error, warn, info, or debug |
| `-v`, `--verbose` | `bool` | `false` | trigger to use verbose logging |
{.clidoc-flags-table}

---

Generated from `amfelt` v5.6.3.
