Manage targets
Targets are
Boundary resources that 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.
This tutorial demonstrates 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.
Warning
All resource IDs in this tutorial are illustrations only. IDs are uniquely generated for every resource upon creation with the exception being generated resources in development mode. Be sure to use the resource IDs that are generated for your environment.
You will create a host catalog, a host set containing hosts, and a target.
Prerequisites
This tutorial assumes that you successfully completed the Manage Scopes tutorial.
Setup a PostgreSQL target
Deploy a postgres database container, which will be configured as a target.
Launch the container by passing the postgres password, sample database name, and URL port mapping as options. In this example the sample database is named "sample".
Export the database URL as an environment variable.
Next, start the Postgres container.
Check that the container is running.
Add hosts to project
Hosts and host sets are defined within a host catalog, so you need to create a host catalog first.
To start this tutorial, be sure to Login to the Boundary Console first.
Create a host catalog named, "DevOps" with description, "For DevOps usage" in the
QA_Tests
project.Example output:
Copy the generated host catalog ID and save it as an environment variabe,
HOST_CATALOG_ID
.Example:
Now, create a new host named, "postgres" with description, "Postgres host" under the newly created host catalog.
Example output:
Repeat the step to create another host named, "localhost".
Example output:
Create a host set
A host set groups together hosts. These hosts provide logically equivalent services.
Note
A target works off of host sets. Therefore, even if there is only one host, you still create a host set containing one host.
Create a host set named, "test-machines".
Example output:
Copy the
test-machines
host set ID and save it as an environment variable,HOST_SET_ID
.. In the example, the ID ishsst_X8gmzYXbO4
.Example:
Retrieve the host IDs.
In the example output, the
postgres
host ID ishst_U1qYKzKfXO
and thelocalhost
host ID ishst_FrdNPd9Zm9
. You will pass these IDs in the next step.Add
postgres
andlocalhost
hosts to thetest-machines
host set. Be sure to replace<postgres_host_id>
and<localhost_host_id>
with the host IDs you just retrieved.Example:
Define a target
Finally, create a target associated with the QA_Tests
project.
Create a target named, "postgres" with description, "Postgres target". Set the default port to be
16001
. To allow unlimited number of session connections, set the session connection limit to-1
.Example output:
In this example, the generated target ID is
ttcp_34yV5O9cwt
. Notice that target IDs starts withttcp_
.Copy the ID of the
tests
target and save it as an environment variable,TARGET_ID
.Example:
Add the
test-machines
host set to thepostgres
target. Replace<target_id>
with your postgres target ID, and<host_set_id>
with your test-machines host set ID.
Manage targets
First, verify you can connect to the target. Then update the target description.
Open a session to the postgres target using boundary connect
. When prompted,
enter the password secret
to connect.
Note
If you followed the Admin Console workflow and did not export the
TARGET_ID
environment variable, supply it directly instead. In this example
the target ID is ttcp_34yV5O9cwt
.
After successfully testing the connection, terminate the session by executing
\q
.
Targets can be managed using arguments to the boundary targets
command, such
as update
, delete
, add-host-sources
and delete-host-sources
.
Update the target description.
Next steps
This tutorial demonstrated the steps to define and manage targets under a scope
(QA_Tests
). Targets represent network services a user can connect to, such as
the postgres
Docker container.
In the Manage Users and Groups
tutorial, you will add and manage users in the org
scope.