consul/website/content/commands/acl/policy/update.mdx

92 lines
2.6 KiB
Plaintext
Raw Normal View History

---
layout: commands
2020-04-07 18:55:19 +00:00
page_title: 'Commands: ACL Policy Update'
---
# Consul ACL Policy Update
Command: `consul acl policy update`
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.
## 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'
#### Command Options
2020-04-07 18:55:19 +00:00
- `-description=<string>` - A description of the policy.
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
2020-04-07 18:55:19 +00:00
- `-meta` - Indicates that policy metadata such as the content hash and raft
indices should be shown for each entry
2020-04-07 18:55:19 +00:00
- `-name=<string>` - The policy's name.
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.
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.
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.
2020-04-07 18:55:19 +00:00
- `-format={pretty|json}` - Command output format. The default value is `pretty`.
#### Enterprise Options
2020-04-07 18:55:19 +00:00
@include 'http_api_namespace_options.mdx'
## Examples
Update a policy:
2020-05-19 18:32:38 +00:00
```shell-session
$ 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
$ 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"
}
```