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:

  1. The host address is 127.0.0.1
  2. The target port is :5432

CLIAdmin ConsoleTerraform

Manage Targets - 图1

Manage Targets - 图2

  1. boundary hosts create static -name postgres -description "Postgres host" -address "127.0.0.1" -host-catalog-id "hcst_1234567890"
  2. Host information:
  3. Created Time: Mon, 28 Sep 2020 18:12:39 PDT
  4. Description: Postgres host
  5. Host Catalog ID: hcst_1234567890
  6. ID: hst_N5l67hLYrQ
  7. Name: postgres
  8. Type: static
  9. Updated Time: Mon, 28 Sep 2020 18:12:39 PDT
  10. Version: 1
  11. Scope:
  12. ID: p_1234567890
  13. Name: Generated project scope
  14. Parent Scope ID: o_1234567890
  15. Type: project
  16. Attributes:
  17. 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

Manage Targets - 图3

Manage Targets - 图4

  1. boundary host-sets create static -name "postgres" -description "Postgres host set" -host-catalog-id hcst_1234567890
  2. Host Set information:
  3. Created Time: Mon, 28 Sep 2020 18:27:10 PDT
  4. Description: Postgres host set
  5. Host Catalog ID: hcst_1234567890
  6. ID: hsst_z7gDCPSig5
  7. Name: postgres
  8. Type: static
  9. Updated Time: Mon, 28 Sep 2020 18:27:10 PDT
  10. Version: 1
  11. Scope:
  12. ID: p_1234567890
  13. Name: Generated project scope
  14. Parent Scope ID: o_1234567890
  15. Type: project

Define a Target

CLIAdmin ConsoleTerraform

Manage Targets - 图5

Manage Targets - 图6

  1. boundary targets create tcp -name 'postgres' -description 'Postgres target' -default-port 5432 -scope-id p_1234567890 -session-connection-limit '-1'
  2. Target information:
  3. Created Time: Mon, 28 Sep 2020 18:43:12 PDT
  4. Description: Postgres target
  5. ID: ttcp_CzVQA3adBf
  6. Name: postgres
  7. Session Connection Limit: -1
  8. Session Max Seconds: 28800
  9. Type: tcp
  10. Updated Time: Mon, 28 Sep 2020 18:43:12 PDT
  11. Version: 1
  12. Scope:
  13. ID: p_1234567890
  14. Name: Generated project scope
  15. Parent Scope ID: o_1234567890
  16. Type: project
  17. Attributes:
  18. Default Port: 5432