Manage Targets
Targets are Boundary resources which contain one or more 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 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.
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:
- The host address is
127.0.0.1
- The target port is
:5432
CLIAdmin ConsoleTerraform
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
Define a Host Set
Host sets allow us to group hosts providing equivalient 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.
CLIAdmin ConsoleTerraform
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
Define a Target
CLIAdmin ConsoleTerraform
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