2019-05-01 21:11:23 +00:00
|
|
|
---
|
2020-09-01 15:14:13 +00:00
|
|
|
layout: commands
|
2020-04-07 18:55:19 +00:00
|
|
|
page_title: 'Commands: ACL Policy Update'
|
2019-05-01 21:11:23 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul ACL Policy Update
|
|
|
|
|
|
|
|
Command: `consul acl policy update`
|
|
|
|
|
2022-01-11 13:26:58 +00:00
|
|
|
Corresponding HTTP API Endpoint: [\[PUT\] /v1/acl/policy/:id](/api-docs/acl/policies#update-a-policy)
|
2022-01-10 17:40:11 +00:00
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
The `acl policy update` command is used to update a policy. The default operations is to merge the current policy
|
|
|
|
with those values provided to the command invocation. Therefore to update just one field, only
|
|
|
|
the `-id` or `-name` options and the option to modify must be provided. Note that renaming
|
|
|
|
policies requires both the `-id` and `-name` as the new name cannot yet be used to lookup the
|
|
|
|
policy.
|
|
|
|
|
2022-01-10 21:44:56 +00:00
|
|
|
The table below shows this command's [required ACLs](/api#authentication). Configuration of
|
2022-03-30 21:16:26 +00:00
|
|
|
[blocking queries](/api-docs/features/blocking) and [agent caching](/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.
|
|
|
|
|
|
|
|
| ACL Required |
|
|
|
|
| ------------ |
|
|
|
|
| `acl:write` |
|
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul acl policy update [options] [args]`
|
|
|
|
|
|
|
|
#### API Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_client.mdx'
|
2020-04-07 23:56:08 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_server.mdx'
|
2019-05-01 21:11:23 +00:00
|
|
|
|
|
|
|
#### Command Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-description=<string>` - A description of the policy.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-id=<string>` - The ID of the policy to update. It may be specified as a
|
|
|
|
unique ID prefix but will error if the prefix matches multiple policy IDs
|
2019-05-01 21:11:23 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-meta` - Indicates that policy metadata such as the content hash and raft
|
2019-05-01 21:11:23 +00:00
|
|
|
indices should be shown for each entry
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-name=<string>` - The policy's name.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-no-merge` - Do not merge the current policy information with what is provided
|
|
|
|
to the command. Instead overwrite all fields with the exception of
|
|
|
|
the policy ID which is immutable.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-rules=<string>` - The policy rules. May be prefixed with `@` to indicate that
|
|
|
|
the value is a file path to load the rules from. `-` may also be given to
|
|
|
|
indicate that the rules are available on stdin.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-valid-datacenter=<value>` - Datacenter that the policy should be valid within.
|
|
|
|
This flag may be specified multiple times.
|
2019-05-01 21:11:23 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-format={pretty|json}` - Command output format. The default value is `pretty`.
|
2020-03-26 16:03:22 +00:00
|
|
|
|
2019-12-06 16:14:56 +00:00
|
|
|
#### Enterprise Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_namespace_options.mdx'
|
2019-12-06 16:14:56 +00:00
|
|
|
|
2021-12-15 01:55:21 +00:00
|
|
|
@include 'http_api_partition_options.mdx'
|
|
|
|
|
2019-05-01 21:11:23 +00:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
Update a policy:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2019-05-01 21:11:23 +00:00
|
|
|
$ consul acl policy update -id 35b8 -name "replication" -description "Policy capable of replication ACL policies and Intentions" -rules @rules.hcl
|
|
|
|
Policy updated successfully
|
|
|
|
ID: 35b8ecb0-707c-ee18-2002-81b238b54b38
|
|
|
|
Name: replication
|
|
|
|
Description: Policy capable of replication ACL policies and Intentions
|
|
|
|
Datacenters:
|
|
|
|
Rules:
|
|
|
|
acl = "read"
|
|
|
|
|
|
|
|
service_prefix "" {
|
|
|
|
policy = "read"
|
|
|
|
intentions = "read"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Rename a policy:
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2019-05-01 21:11:23 +00:00
|
|
|
$ consul acl policy update -id 35b8 -name "dc1-replication"
|
|
|
|
Policy updated successfully
|
|
|
|
ID: 35b8ecb0-707c-ee18-2002-81b238b54b38
|
|
|
|
Name: dc1-replication
|
|
|
|
Description: Policy capable of replication ACL policies and Intentions
|
|
|
|
Datacenters: dc1
|
|
|
|
Rules:
|
|
|
|
acl = "read"
|
|
|
|
|
|
|
|
service_prefix "" {
|
|
|
|
policy = "read"
|
|
|
|
intentions = "read"
|
|
|
|
}
|
|
|
|
```
|