feat(coder/modules/boundary): add boundary module#840
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new coder/boundary registry module intended to set up Boundary-related tooling for Coder workspaces.
Changes:
- Introduces a Boundary install/setup shell script that can compile from source, install from release, or rely on
coder boundary. - Adds a Terraform module (
main.tf) that deploys and runs the install script on an agent. - Adds module README and Terraform native tests (
.tftest.hcl).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
registry/coder/modules/boundary/scripts/install.sh |
Installs Boundary (or validates coder boundary) and generates a wrapper script. |
registry/coder/modules/boundary/main.tf |
Defines module variables and a coder_script to deliver/execute install.sh. |
registry/coder/modules/boundary/README.md |
Documents module usage and examples. |
registry/coder/modules/boundary/boundary.tftest.hcl |
Adds Terraform plan-time assertions for basic module wiring. |
| echo "Compiling boundary from source (version: ${BOUNDARY_VERSION})" | ||
|
|
||
| # Remove existing boundary directory to allow re-running safely | ||
| if [[ -d boundary ]]; then | ||
| rm -rf boundary | ||
| fi | ||
|
|
||
| echo "Cloning boundary repository" | ||
| git clone https://github.com/coder/boundary.git | ||
| cd boundary || exit 1 | ||
| git checkout "${BOUNDARY_VERSION}" | ||
|
|
||
| make build | ||
|
|
||
| sudo cp boundary /usr/local/bin/ | ||
| sudo chmod +x /usr/local/bin/boundary | ||
| cd - || exit 1 |
There was a problem hiding this comment.
The source-compile path deletes and clones a boundary/ directory relative to the current working directory (rm -rf boundary, git clone ..., cd boundary). If this script is invoked from an unexpected directory, it can delete the wrong folder and/or pollute the workspace. Prefer cloning/building under ${MODULE_DIR} (or a mktemp -d under it) and using an absolute path for cleanup.
| echo "Compiling boundary from source (version: ${BOUNDARY_VERSION})" | |
| # Remove existing boundary directory to allow re-running safely | |
| if [[ -d boundary ]]; then | |
| rm -rf boundary | |
| fi | |
| echo "Cloning boundary repository" | |
| git clone https://github.com/coder/boundary.git | |
| cd boundary || exit 1 | |
| git checkout "${BOUNDARY_VERSION}" | |
| make build | |
| sudo cp boundary /usr/local/bin/ | |
| sudo chmod +x /usr/local/bin/boundary | |
| cd - || exit 1 | |
| local build_dir="${MODULE_DIR}/boundary-src" | |
| local original_dir | |
| echo "Compiling boundary from source (version: ${BOUNDARY_VERSION})" | |
| original_dir="$(pwd)" | |
| # Remove existing build directory to allow re-running safely | |
| if [[ -d "${build_dir}" ]]; then | |
| rm -rf "${build_dir}" | |
| fi | |
| echo "Cloning boundary repository" | |
| git clone https://github.com/coder/boundary.git "${build_dir}" | |
| cd "${build_dir}" || exit 1 | |
| git checkout "${BOUNDARY_VERSION}" | |
| make build | |
| sudo cp "${build_dir}/boundary" /usr/local/bin/ | |
| sudo chmod +x /usr/local/bin/boundary | |
| cd "${original_dir}" || exit 1 |
| cd - || exit 1 | ||
| elif [[ "${USE_BOUNDARY_DIRECTLY}" = "true" ]]; then | ||
| echo "Installing boundary using official install script (version: ${BOUNDARY_VERSION})" | ||
| curl -fsSL https://raw.githubusercontent.com/coder/boundary/main/install.sh | bash -s -- --version "${BOUNDARY_VERSION}" |
There was a problem hiding this comment.
curl ... | bash executes a remote script from the main branch. Even with --version, this is supply-chain risky and not reproducible. Prefer downloading a version-pinned artifact (or install script from a tag/commit), verifying a checksum/signature, and then executing it.
| curl -fsSL https://raw.githubusercontent.com/coder/boundary/main/install.sh | bash -s -- --version "${BOUNDARY_VERSION}" | |
| if [[ "${BOUNDARY_VERSION}" = "latest" ]]; then | |
| echo "Error: use_boundary_directly requires a version-pinned ARG_BOUNDARY_VERSION, not 'latest'." >&2 | |
| exit 1 | |
| fi | |
| local install_script | |
| install_script="$(mktemp)" | |
| curl -fsSL "https://raw.githubusercontent.com/coder/boundary/${BOUNDARY_VERSION}/install.sh" -o "${install_script}" | |
| bash "${install_script}" --version "${BOUNDARY_VERSION}" | |
| rm -f "${install_script}" |
| setup_boundary() { | ||
| local module_path="${MODULE_DIR}" | ||
|
|
||
| echo "Setting up coder boundary..." | ||
|
|
||
| # Install boundary binary if needed | ||
| install_boundary | ||
|
|
||
| # Determine which boundary command to use and create wrapper script | ||
| BOUNDARY_WRAPPER_SCRIPT="${module_path}/boundary-wrapper.sh" | ||
|
|
There was a problem hiding this comment.
setup_boundary relies on MODULE_DIR being set; if it’s empty, paths like ${module_path}/boundary-wrapper.sh become /boundary-wrapper.sh and the script may write into the filesystem root. Add a guard that MODULE_DIR is non-empty (and ideally exists / is writable) before creating wrapper scripts.
Description
Type of Change
Module Information
Path:
registry/coder/modules/boundaryNew version:
v1.0.0Breaking change: [ ] Yes [x] No
Testing & Validation
bun test)bun fmt)Related Issues