June 20-22 Announcing HashiConf Europe full schedule: keynotes, sessions, labs & more Register Now
  • Overview
    • Consul on Kubernetes
    • Control access with Consul API Gateway
    • Discover Services with Consul
    • Enforce Zero Trust Networking with Consul
    • Load Balancing with Consul
    • Manage Traffic with Consul
    • Multi-Platform Service Mesh with Consul
    • Network Infrastructure Automation with Consul
    • Observability with Consul
  • Enterprise
  • Tutorials
  • Docs
  • API
  • CLI
  • Community
GitHub
Download
Try HCP Consul
    • v1.12.x (latest)
    • v1.11.x
    • v1.10.x
    • v1.9.x
    • v1.8.x
  • Commands (CLI)
    • Overview
      • Overview
      • create
      • delete
      • list
      • read
      • update
      • Overview
      • create
      • delete
      • list
      • read
      • update
    • bootstrap
      • Overview
      • create
      • delete
      • list
      • read
      • update
      • Overview
      • create
      • delete
      • list
      • read
      • update
    • set-agent-token
      • Overview
      • clone
      • create
      • delete
      • list
      • read
      • update
    • translate-rules
  • agent
    • Overview
    • datacenters
    • nodes
    • services
    • Overview
    • delete
    • list
    • read
    • write
    • Overview
    • ca
    • proxy
    • envoy
    • expose
    • redirect-traffic
  • debug
  • event
  • exec
  • force-leave
  • info
    • Overview
    • check
    • create
    • delete
    • get
    • list
    • match
  • join
  • keygen
  • keyring
    • Overview
    • delete
    • export
    • get
    • import
    • put
  • leave
  • license
  • lock
  • login
  • logout
  • maint
  • members
  • monitor
    • Overview
    • create
    • delete
    • list
    • read
    • update
    • write
    • Overview
    • area
    • autopilot
    • raft
  • partition
  • reload
  • rtt
    • Overview
    • register
    • deregister
    • Overview
    • agent
    • inspect
    • restore
    • save
    • Overview
    • ca
    • cert
  • validate
  • version
  • watch
Type '/' to Search

»Consul ACL Policies

Command: consul acl policy

The acl policy command is used to manage Consul's ACL policies. It exposes commands for creating, updating, reading, deleting, and listing policies. This command is available in Consul 1.4.0 and newer.

ACL policies may also be managed via the HTTP API.

Note: All of the example subcommands in this document will require a valid Consul token with the appropriate permissions. Either set the CONSUL_HTTP_TOKEN environment variable to the token's secret ID or pass the secret ID as the value of the -token parameter.

»Usage

Usage: consul acl policy <subcommand>

For the exact documentation for your Consul version, run consul acl policy -h to view the complete list of subcommands.

Usage: consul acl policy <subcommand> [options] [args]

  ...

Subcommands:
    create    Create an ACL policy
    delete    Delete an ACL policy
    list      Lists ACL policies
    read      Read an ACL policy
    update    Update an ACL policy
Usage: consul acl policy <subcommand> [options] [args]

  ...

Subcommands:
    create    Create an ACL policy
    delete    Delete an ACL policy
    list      Lists ACL policies
    read      Read an ACL policy
    update    Update an ACL policy

For more information, examples, and usage about a subcommand, click on the name of the subcommand in the sidebar.

»Identifying Policies

Several of the subcommands need to operate on a specific policy. Those subcommands support specifying the policy by its ID using the -id parameter or by name using the -name parameter.

When specifying the policy by its ID a unique policy ID prefix may be specified instead of the entire UUID. As long as it is unique it will be resolved to the full UUID and used. Additionally builtin policy names will be accepted as the value to the -id parameter. Even if the builtin policies are renamed their original name can be used to operate on them.

Builtin policies:

Policy UUIDPolicy Name
00000000-0000-0000-0000-000000000001global-management

»Basic Examples

Create a new ACL policy:

$ consul acl policy create -name "new-policy" \
                         -description "This is an example policy" \
                         -datacenter "dc1" \
                         -datacenter "dc2" \
                         -rules @rules.hcl
$ consul acl policy create -name "new-policy" \
                         -description "This is an example policy" \
                         -datacenter "dc1" \
                         -datacenter "dc2" \
                         -rules @rules.hcl

List all policies:

$ consul acl policy list
$ consul acl policy list

Update a policy:

$ consul acl policy update -name "other-policy" -datacenter "dc1"
$ consul acl policy update -name "other-policy" -datacenter "dc1"

Read a policy:

$ consul acl policy read -id 0479e93e-091c-4475-9b06-79a004765c24
$ consul acl policy read -id 0479e93e-091c-4475-9b06-79a004765c24

Delete a policy

$ consul acl policy delete -name "my-policy"
$ consul acl policy delete -name "my-policy"
github logoEdit this page
IntroGuidesDocsCommunityPrivacySecurityBrandConsent Manager