2018-05-29 21:07:40 +00:00
|
|
|
---
|
2020-04-07 18:55:19 +00:00
|
|
|
layout: docs
|
2020-04-06 20:27:35 +00:00
|
|
|
page_title: 'Commands: Intention'
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: intention
|
2018-05-29 21:07:40 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Intention
|
|
|
|
|
|
|
|
Command: `consul intention`
|
|
|
|
|
|
|
|
The `intention` command is used to interact with Connect
|
2020-04-09 23:46:54 +00:00
|
|
|
[intentions](/docs/connect/intentions). It exposes commands for
|
2018-05-29 21:07:40 +00:00
|
|
|
creating, updating, reading, deleting, checking, and managing intentions.
|
|
|
|
This command is available in Consul 1.2 and later.
|
|
|
|
|
2020-04-09 23:46:54 +00:00
|
|
|
Intentions may also be managed via the [HTTP API](/api/connect/intentions).
|
2018-05-29 21:07:40 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul intention <subcommand>`
|
|
|
|
|
|
|
|
For the exact documentation for your Consul version, run `consul intention -h` to view
|
|
|
|
the complete list of subcommands.
|
|
|
|
|
|
|
|
```text
|
|
|
|
Usage: consul intention <subcommand> [options] [args]
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
Subcommands:
|
|
|
|
check Check whether a connection between two services is allowed.
|
|
|
|
create Create intentions for service connections.
|
|
|
|
delete Delete an intention.
|
|
|
|
get Show information about an intention.
|
|
|
|
match Show intentions that match a source or destination.
|
|
|
|
```
|
|
|
|
|
|
|
|
For more information, examples, and usage about a subcommand, click on the name
|
|
|
|
of the subcommand in the sidebar.
|
|
|
|
|
|
|
|
## Basic Examples
|
|
|
|
|
|
|
|
Create an intention to allow "web" to talk to "db":
|
|
|
|
|
2020-09-01 18:29:41 +00:00
|
|
|
```shell-session
|
2020-04-07 23:56:08 +00:00
|
|
|
$ consul intention create web db
|
|
|
|
```
|
2018-05-29 21:07:40 +00:00
|
|
|
|
2020-05-13 21:29:40 +00:00
|
|
|
Create an intention to deny "db" from initiating connections to _any_ service:
|
|
|
|
|
2020-09-01 18:29:41 +00:00
|
|
|
```shell-session
|
2020-05-13 21:29:40 +00:00
|
|
|
$ consul intention create -deny db '*'
|
|
|
|
Created: db => * (deny)
|
|
|
|
```
|
|
|
|
|
2018-05-29 21:07:40 +00:00
|
|
|
Test whether a "web" is allowed to connect to "db":
|
|
|
|
|
2020-09-01 18:29:41 +00:00
|
|
|
```shell-session
|
2020-04-07 23:56:08 +00:00
|
|
|
$ consul intention check web db
|
|
|
|
```
|
2018-05-29 21:07:40 +00:00
|
|
|
|
|
|
|
Find all intentions for communicating to the "db" service:
|
|
|
|
|
2020-09-01 18:29:41 +00:00
|
|
|
```shell-session
|
2020-04-07 23:56:08 +00:00
|
|
|
$ consul intention match db
|
|
|
|
```
|
2020-09-01 18:29:41 +00:00
|
|
|
|
|
|
|
## Source and Destination Naming
|
|
|
|
|
|
|
|
Intention commands commonly take positional arguments referred to as `SRC` and
|
|
|
|
`DST` in the command documentation. These can take several forms:
|
|
|
|
|
|
|
|
| Format | Meaning |
|
|
|
|
| ----------------------- | -----------------------------------------------------------------------|
|
|
|
|
| `<service>` | the named service in the current namespace |
|
|
|
|
| `*` | any service in the current namespace |
|
|
|
|
| `<namespace>/<service>` | <EnterpriseAlert inline /> the named service in a specific namespace |
|
|
|
|
| `<namespace>/*` | <EnterpriseAlert inline /> any service in the specified namespace |
|
|
|
|
| `*/*` | <EnterpriseAlert inline /> any service in any namespace |
|