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'
|
2023-01-26 18:42:13 +00:00
|
|
|
description: >-
|
|
|
|
The `consul config write` command creates or updates a configuration entry and applies it to your deployment.
|
2019-05-01 18:21:11 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Config Write
|
|
|
|
|
|
|
|
Command: `consul config write`
|
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
Corresponding HTTP API Endpoint: [\[PUT\] /v1/config](/consul/api-docs/config#apply-configuration)
|
2022-01-10 17:40:11 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
The `config write` command creates or updates a centralized config entry.
|
2023-01-25 16:52:43 +00:00
|
|
|
See the [configuration entries docs](/consul/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
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of
|
|
|
|
[blocking queries](/consul/api-docs/features/blocking) and [agent caching](/consul/api-docs/features/caching)
|
2022-01-10 21:44:56 +00:00
|
|
|
are not supported from commands, but may be from the corresponding HTTP endpoint.
|
|
|
|
|
2022-01-11 14:41:54 +00:00
|
|
|
| ACL Required<sup>1</sup> |
|
|
|
|
| ------------------------------------------------------------- |
|
|
|
|
| `service:write`<br />`operator:write`<br />`intentions:write` |
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<sup>1</sup> The actual ACL required depends on the config entry kind being
|
|
|
|
updated:
|
|
|
|
</p>
|
|
|
|
|
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ------------------- | ------------------ |
|
2023-03-20 16:37:30 +00:00
|
|
|
| api-gateway | `mesh:write` |
|
2022-01-11 14:41:54 +00:00
|
|
|
| ingress-gateway | `operator:write` |
|
|
|
|
| proxy-defaults | `operator:write` |
|
|
|
|
| service-defaults | `service:write` |
|
|
|
|
| service-intentions | `intentions:write` |
|
|
|
|
| service-resolver | `service:write` |
|
|
|
|
| service-router | `service:write` |
|
|
|
|
| service-splitter | `service:write` |
|
|
|
|
| terminating-gateway | `operator:write` |
|
2022-01-10 21:44:56 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul config write [options] FILE`
|
|
|
|
|
2022-07-27 06:17:11 +00:00
|
|
|
#### Command Options
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-07-27 06:17:11 +00:00
|
|
|
- `-cas` - Specifies to use a Check-And-Set operation. If the index is
|
|
|
|
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`
|
|
|
|
of that entry.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-02-07 20:01:04 +00:00
|
|
|
#### Enterprise Options
|
|
|
|
|
2024-07-18 17:02:45 +00:00
|
|
|
@include 'cli-http-api-partition-options.mdx'
|
2021-12-15 01:55:21 +00:00
|
|
|
|
2022-07-27 06:17:11 +00:00
|
|
|
@include 'http_api_namespace_options.mdx'
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-07-27 06:17:11 +00:00
|
|
|
#### API Options
|
|
|
|
|
|
|
|
@include 'http_api_options_client.mdx'
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
From file:
|
|
|
|
|
|
|
|
$ consul config write web-defaults.json
|
|
|
|
|
|
|
|
From stdin:
|
|
|
|
|
|
|
|
$ consul config write -
|
|
|
|
|
|
|
|
### Config Entry examples
|
|
|
|
|
2022-01-19 19:50:57 +00:00
|
|
|
All config entries must have a `Kind` when registered. See
|
2023-01-25 16:52:43 +00:00
|
|
|
[Service Mesh - Config Entries](/consul/docs/connect/config-entries) for the list of
|
2022-01-19 19:50:57 +00:00
|
|
|
supported config entries.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
#### Service defaults
|
|
|
|
|
2023-05-05 17:41:40 +00:00
|
|
|
Service defaults control default global values for a service in the service mesh.
|
|
|
|
For example, the following configuration defines that all instances of the `web`
|
|
|
|
service use the `http` protocol.
|
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
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-05-05 17:41:40 +00:00
|
|
|
For more information, refer to the [service defaults configuration reference](/consul/docs/connect/config-entries/service-defaults).
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
#### Proxy defaults
|
|
|
|
|
2023-05-05 17:41:40 +00:00
|
|
|
Proxy defaults lets you configure global config defaults across all proxies
|
|
|
|
in the service mesh. Currently, it supports only one global entry.
|
|
|
|
For example, the following configuration overrides a default timeout for all
|
|
|
|
Envoy proxies.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-07 18:55:19 +00:00
|
|
|
"Kind": "proxy-defaults",
|
|
|
|
"Name": "global",
|
|
|
|
"Config": {
|
2023-05-05 17:41:40 +00:00
|
|
|
"local_idle_timeout_ms": 20000
|
2020-04-07 18:55:19 +00:00
|
|
|
}
|
2019-05-01 18:21:11 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-05-05 17:41:40 +00:00
|
|
|
For more information, refer to the [proxy defaults configuration reference](/consul/docs/connect/config-entries/proxy-defaults).
|