mirror of https://github.com/hashicorp/boundary
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
246 lines
8.1 KiB
246 lines
8.1 KiB
---
|
|
layout: docs
|
|
page_title: Manage Targets
|
|
description: How to manage Boundary targets
|
|
---
|
|
|
|
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
|
|
> [!IMPORTANT]
|
|
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
|
|
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
|
|
|
|
# Manage Targets
|
|
|
|
[Targets](/boundary/docs/domain-model/targets) are Boundary resources which contain one or more [Host Sets](/boundary/docs/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](/boundary/docs/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.
|
|
|
|
~> Note that all resource IDs in this example are illustration only - IDs are uniquely generated for every resource upon creation with the exception being
|
|
generated resources in `dev` mode. Please make sure to use the resource IDs that are generated when running this example. For example, if you run
|
|
`boundary users create`, use the resource ID of the user seen in stdout, not the ID in the example command.
|
|
|
|
## 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`
|
|
|
|
<Tabs>
|
|
<Tab heading="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
|
|
```
|
|
|
|
</Tab>
|
|
<Tab heading="Admin Console">
|
|
|
|
1. Navigate to a host catalog (Projects > Project > Host Catalogs > Host Catalog).
|
|
1. Choose **New Host** from the **Manage** dropdown.
|
|
1. Fill host details.
|
|
1. Choose **Save** and view the host edit form page.
|
|
|
|
<video muted playsInline autoPlay loop class="boundary-clickthrough-video">
|
|
<source
|
|
type="video/mp4"
|
|
src="https://www.datocms-assets.com/2885/1602267180-boundary-clickthrough-manage-targets-create-host.mp4"
|
|
/>
|
|
</video>
|
|
|
|
</Tab>
|
|
<Tab heading="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"
|
|
}
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
## Define a Host Set
|
|
|
|
Host sets allow us to group hosts providing equivalent services 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.
|
|
|
|
<Tabs>
|
|
<Tab heading="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
|
|
```
|
|
|
|
</Tab>
|
|
<Tab heading="Admin Console">
|
|
|
|
1. Navigate to a host catalog, then to the **Host Sets** tab.
|
|
1. Choose **Create Host Set** from the **Manage** dropdown.
|
|
1. Fill host set details.
|
|
1. Choose **Save** and view the host set edit form page.
|
|
|
|
<video muted playsInline autoPlay loop class="boundary-clickthrough-video">
|
|
<source
|
|
type="video/mp4"
|
|
src="https://www.datocms-assets.com/2885/1603385847-boundary-clickthrough-manage-targets-create-host-set-v0-1-1.mp4"
|
|
/>
|
|
</video>
|
|
|
|
Then associate the host set with a host:
|
|
|
|
1. From the host set edit form, navigate to the **Hosts** tab.
|
|
1. Choose **Add Existing Host** from the **Manage** dropdown.
|
|
1. Select one or more hosts to associate with the host set.
|
|
1. Choose the **Add Hosts** button and view the hosts list.
|
|
|
|
<video muted playsInline autoPlay loop class="boundary-clickthrough-video">
|
|
<source
|
|
type="video/mp4"
|
|
src="https://www.datocms-assets.com/2885/1603385876-boundary-clickthrough-manage-targets-assign-host-to-host-set-v0-1-1.mp4"
|
|
/>
|
|
</video>
|
|
|
|
</Tab>
|
|
<Tab heading="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 = "hcst_1234567890"
|
|
|
|
// taken from the Terraform example above
|
|
host_ids = [ boundary_host.postgres.id ]
|
|
}
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
## Define a Target
|
|
|
|
<Tabs>
|
|
<Tab heading="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
|
|
```
|
|
|
|
</Tab>
|
|
<Tab heading="Admin Console">
|
|
|
|
1. Navigate to a project, then to targets.
|
|
1. Choose the **New** button.
|
|
1. Fill the target details.
|
|
1. Choose **Save** and view the host set edit form page.
|
|
|
|
<video muted playsInline autoPlay loop class="boundary-clickthrough-video">
|
|
<source
|
|
type="video/mp4"
|
|
src="https://www.datocms-assets.com/2885/1602261018-boundary-clickthrough-manage-targets-create-target.mp4"
|
|
/>
|
|
</video>
|
|
|
|
Then associate the host set with a host:
|
|
|
|
1. From the target edit form, navigate to the **Host Sets** tab.
|
|
1. Choose **Add Host Sets** from the **Manage** dropdown.
|
|
1. Select one or more host sets to associate with the target.
|
|
1. Choose the **Add Host Sets** button and view the host sets list.
|
|
|
|
<video muted playsInline autoPlay loop class="boundary-clickthrough-video">
|
|
<source
|
|
type="video/mp4"
|
|
src="https://www.datocms-assets.com/2885/1602261011-boundary-clickthrough-manage-targets-assign-host-set-to-target.mp4"
|
|
/>
|
|
</video>
|
|
|
|
</Tab>
|
|
<Tab heading="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
|
|
]
|
|
}
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|