2019-05-01 18:21:11 +00:00
|
|
|
---
|
2020-09-01 15:14:13 +00:00
|
|
|
layout: commands
|
2020-04-07 18:55:19 +00:00
|
|
|
page_title: 'Commands: Config Write'
|
2019-05-01 18:21:11 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Config Write
|
|
|
|
|
|
|
|
Command: `consul config write`
|
|
|
|
|
2022-01-10 17:40:11 +00:00
|
|
|
Corresponding HTTP API Endpoint: [\[PUT\] /v1/config](https://www.consul.io/api-docs/config#apply-configuration)
|
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
The `config write` command creates or updates a centralized config entry.
|
2020-10-14 15:23:05 +00:00
|
|
|
See the [configuration entries docs](/docs/agent/config-entries) for more
|
2019-05-08 20:19:37 +00:00
|
|
|
details about configuration entries.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-01-10 21:44:56 +00:00
|
|
|
The table below shows this command's [required ACLs](/api#authentication). Configuration of
|
|
|
|
[blocking queries](/api/features/blocking) and [agent caching](/api/features/caching)
|
|
|
|
are not supported from commands, but may be from the corresponding HTTP endpoint.
|
|
|
|
|
|
|
|
| ACL Required |
|
|
|
|
| ----------------------------------- |
|
|
|
|
| `service:write` or `operator:write` |
|
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul config write [options] FILE`
|
|
|
|
|
|
|
|
#### API Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_client.mdx'
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-02-07 20:01:04 +00:00
|
|
|
#### Enterprise Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_namespace_options.mdx'
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2021-12-15 01:55:21 +00:00
|
|
|
@include 'http_api_partition_options.mdx'
|
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
#### Config Write Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-cas` - Specifies to use a Check-And-Set operation. If the index is
|
2019-05-08 20:19:37 +00:00
|
|
|
0, Consul will only store the entry if it does not already exist. If the index is
|
|
|
|
non-zero, the entry is only set if the current index matches the `ModifyIndex`
|
2019-05-01 18:21:11 +00:00
|
|
|
of that entry.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
From file:
|
|
|
|
|
|
|
|
$ consul config write web-defaults.json
|
|
|
|
|
|
|
|
From stdin:
|
|
|
|
|
|
|
|
$ consul config write -
|
|
|
|
|
|
|
|
### Config Entry examples
|
|
|
|
|
|
|
|
All config entries must have a `Kind` when registered. Currently, the only
|
|
|
|
supported types are `service-defaults` and `proxy-defaults`.
|
|
|
|
|
|
|
|
#### Service defaults
|
|
|
|
|
2019-05-08 20:19:37 +00:00
|
|
|
Service defaults control default global values for a service, such as the
|
|
|
|
protocol and Connect fields.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-07 18:55:19 +00:00
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "web",
|
|
|
|
"Protocol": "http"
|
2019-05-01 18:21:11 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `Name` - Sets the name of the config entry. For service defaults, this must be
|
2019-05-01 18:21:11 +00:00
|
|
|
the name of the service being configured.
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `Protocol` - Sets the protocol of the service. This is used by Connect proxies
|
2019-05-01 18:21:11 +00:00
|
|
|
for things like observability features.
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `Connect` - This block contains Connect-related fields for the service.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `SidecarProxy` - Sets whether or not instances of this service should get a
|
2019-05-01 18:21:11 +00:00
|
|
|
sidecar proxy by default.
|
|
|
|
|
|
|
|
#### Proxy defaults
|
|
|
|
|
|
|
|
Proxy defaults allow for configuring global config defaults across all services
|
|
|
|
for Connect proxy config. Currently, only one global entry is supported.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-07 18:55:19 +00:00
|
|
|
"Kind": "proxy-defaults",
|
|
|
|
"Name": "global",
|
|
|
|
"Config": {
|
|
|
|
"foo": 1
|
|
|
|
}
|
2019-05-01 18:21:11 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `Name` - Sets the name of the config entry. Currently, only a single `proxy-defaults`
|
2019-05-01 18:21:11 +00:00
|
|
|
entry with the name `global` is supported.
|
|
|
|
|
|
|
|
* `Config` - An arbitrary map of configuration values used by Connect proxies.
|