docs: add target workflow (#487)
No files matched your search
@@ -6,3 +6,183 @@ description: How to manage Boundary targets
|
||||
---
|
||||
|
||||
# Manage Targets
|
||||
|
||||
[Targets](/docs/concepts/domain-model/targets) are Boundary resources which contain a [host-set](/docs/concepts/domain-model/host-sets). A target allows Boundary users to define an endpoint with a default-port and a protocol to establish a session. Unless specified with a `-host-id` flag, Boundary will choose one [host](/docs/concepts/domain-model/hosts) in the host-set to connect to at random.
|
||||
|
||||
In this section, we'll show you the basics of how to define a host, host-set, and a target in Boundary on the CLI, the admin console, and using our [Terraform provider](https://github.com/hashicorp/terraform-provider-boundary).
|
||||
|
||||
We assume you're running Boundary in dev mode and have a default static host-catalog of `hcst_1234567890`. We also assume you've logged in on the command line and the admin console. See the output of `boundary dev` for these login values.
|
||||
|
||||
## Define a Host
|
||||
|
||||
For this example, we're going to create a target to access postgres on `localhost`. This assumes a couple of things:
|
||||
|
||||
1. The host address is `127.0.0.1`
|
||||
2. The target port is `:5432`
|
||||
|
||||
#### CLI
|
||||
|
||||
```bash
|
||||
boundary hosts create static -name postgres -description "Postgres host" -address "127.0.0.1" -host-catalog-id "hcst_1234567890"
|
||||
|
||||
Host information:
|
||||
Created Time: Mon, 28 Sep 2020 18:12:39 PDT
|
||||
Description: Postgres host
|
||||
Host Catalog ID: hcst_1234567890
|
||||
ID: hst_N5l67hLYrQ
|
||||
Name: postgres
|
||||
Type: static
|
||||
Updated Time: Mon, 28 Sep 2020 18:12:39 PDT
|
||||
Version: 1
|
||||
|
||||
Scope:
|
||||
ID: p_1234567890
|
||||
Name: Generated project scope
|
||||
Parent Scope ID: o_1234567890
|
||||
Type: project
|
||||
|
||||
Attributes:
|
||||
address: 127.0.0.1
|
||||
```
|
||||
|
||||
#### UI
|
||||
|
||||
Navigate to the default host catalog:
|
||||

|
||||
|
||||
Select new host from the `manage` dropdown:
|
||||

|
||||
|
||||
Fill in the required information about our postgres host:
|
||||

|
||||
|
||||
View the host in the catalog:
|
||||

|
||||
|
||||
#### Terraform
|
||||
|
||||
To define this same host using our Terraform provider:
|
||||
|
||||
```hcl
|
||||
resource "boundary_host" "postgres" {
|
||||
type = "static"
|
||||
name = "postgres"
|
||||
description = "Postgres host"
|
||||
address = "127.0.0.1"
|
||||
host_catalog_id = "hcst_1234567890"
|
||||
}
|
||||
```
|
||||
|
||||
## Define a Host-Set
|
||||
|
||||
Host-sets allow us to group hosts of similar interests together. A target works off of host-sets, so even though we are only defining one host in this example, we're going to create a host-set of one host.
|
||||
|
||||
#### CLI
|
||||
|
||||
```bash
|
||||
boundary host-sets create static -name "postgres" -description "Postgres host set" -host-catalog-id hcst_1234567890
|
||||
|
||||
Host Set information:
|
||||
Created Time: Mon, 28 Sep 2020 18:27:10 PDT
|
||||
Description: Postgres host set
|
||||
Host Catalog ID: hcst_1234567890
|
||||
ID: hsst_z7gDCPSig5
|
||||
Name: postgres
|
||||
Type: static
|
||||
Updated Time: Mon, 28 Sep 2020 18:27:10 PDT
|
||||
Version: 1
|
||||
|
||||
Scope:
|
||||
ID: p_1234567890
|
||||
Name: Generated project scope
|
||||
Parent Scope ID: o_1234567890
|
||||
Type: project
|
||||
```
|
||||
|
||||
#### UI
|
||||
|
||||
Navigate to the host catalog and the `host sets` tab, select `Create Host Set` from `manage` dropdown:
|
||||

|
||||
|
||||
Fill in the host-set definition:
|
||||

|
||||
|
||||
See the new host set in the host-catalog view:
|
||||

|
||||
|
||||
#### Terraform
|
||||
|
||||
To define this host-set in Terraform:
|
||||
|
||||
```hcl
|
||||
resource "boundary_host_set" "postgres" {
|
||||
type = "static"
|
||||
name = "postgres"
|
||||
description = "Host set for postgres"
|
||||
host_catalog_id = host_catalog_id = "hcst_1234567890"
|
||||
|
||||
// taken from the Terraform example above
|
||||
host_ids = [ boundary_host.postgres.id ]
|
||||
}
|
||||
```
|
||||
|
||||
## Define Target
|
||||
|
||||
#### CLI
|
||||
|
||||
```bash
|
||||
boundary targets create tcp -name 'postgres' -description 'Postgres target' -default-port 5432 -scope-id p_1234567890 -session-connection-limit '-1'
|
||||
|
||||
Target information:
|
||||
Created Time: Mon, 28 Sep 2020 18:43:12 PDT
|
||||
Description: Postgres target
|
||||
ID: ttcp_CzVQA3adBf
|
||||
Name: postgres
|
||||
Session Connection Limit: -1
|
||||
Session Max Seconds: 28800
|
||||
Type: tcp
|
||||
Updated Time: Mon, 28 Sep 2020 18:43:12 PDT
|
||||
Version: 1
|
||||
|
||||
Scope:
|
||||
ID: p_1234567890
|
||||
Name: Generated project scope
|
||||
Parent Scope ID: o_1234567890
|
||||
Type: project
|
||||
Attributes:
|
||||
Default Port: 5432
|
||||
```
|
||||
|
||||
#### UI
|
||||
|
||||
Navigate to your the default project:
|
||||

|
||||
|
||||
Then the targets view and choose `new` target:
|
||||

|
||||
|
||||
Fill in the Target info:
|
||||

|
||||
|
||||
See the Target in the targets view:
|
||||

|
||||
|
||||
#### Terraform
|
||||
|
||||
To define this target in Terraform:
|
||||
|
||||
```hcl
|
||||
resource "boundary_target" "postgres" {
|
||||
type = "tcp"
|
||||
name = "postgres"
|
||||
description = "Postgres target"
|
||||
scope_id = "p_1234567890"
|
||||
session_connection_limit = -1
|
||||
default_port = 5432
|
||||
|
||||
// taken from the example above
|
||||
host_set_ids = [
|
||||
boundary_host_set.postgres.id
|
||||
]
|
||||
}
|
||||
```
|
||||
|
After Width: | Height: | Size: 271 KiB |
|
After Width: | Height: | Size: 278 KiB |
|
After Width: | Height: | Size: 289 KiB |
|
After Width: | Height: | Size: 287 KiB |
|
After Width: | Height: | Size: 247 KiB |
|
After Width: | Height: | Size: 289 KiB |
|
After Width: | Height: | Size: 286 KiB |
|
After Width: | Height: | Size: 308 KiB |
|
After Width: | Height: | Size: 287 KiB |
|
After Width: | Height: | Size: 270 KiB |
|
After Width: | Height: | Size: 294 KiB |