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

  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
  1. boundary hosts create static -name postgres -description "Postgres host" -address "127.0.0.1" -host-catalog-id "hcst_1234567890"
  2. 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
  3. Scope: ID: p_1234567890 Name: Generated project scope Parent Scope ID: o_1234567890 Type: project
  4. Attributes: address: 127.0.0.1

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.

CLIAdmin ConsoleTerraform

  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
  1. boundary host-sets create static -name "postgres" -description "Postgres host set" -host-catalog-id hcst_1234567890
  2. 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
  3. Scope: ID: p_1234567890 Name: Generated project scope Parent Scope ID: o_1234567890 Type: project

Define a Target

CLIAdmin ConsoleTerraform

  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
  1. boundary targets create tcp -name 'postgres' -description 'Postgres target' -default-port 5432 -scope-id p_1234567890 -session-connection-limit '-1'
  2. 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
  3. Scope: ID: p_1234567890 Name: Generated project scope Parent Scope ID: o_1234567890 Type: project Attributes: Default Port: 5432