Skip to content

Commit f255d6c

Browse files
35C4n0rJay Kumar
authored andcommitted
feat: boundary to agent-firewall refactor
1 parent 02f0bc3 commit f255d6c

5 files changed

Lines changed: 249 additions & 249 deletions

File tree

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
11
---
2-
display_name: Boundary
3-
description: Configures boundary for network isolation in Coder workspaces
2+
display_name: Agent Firewall
3+
description: Configures agent-firewall for network isolation in Coder workspaces
44
icon: ../../../../.icons/coder.svg
55
verified: true
6-
tags: [boundary, ai, agents, firewall]
6+
tags: [agent-firewall, ai, agents, firewall, boundary]
77
---
88

9-
# Boundary
9+
# Agent Firewall
1010

11-
Installs [boundary](https://coder.com/docs/ai-coder/agent-firewall) for network isolation in Coder workspaces.
11+
Installs [agent-firewall](https://coder.com/docs/ai-coder/agent-firewall) for network isolation in Coder workspaces.
1212

1313
This module:
1414

15-
- Installs boundary (via coder subcommand, direct installation, or compilation from source)
16-
- Creates a wrapper script at `$HOME/.coder-modules/coder/boundary/scripts/boundary-wrapper.sh`
17-
- Writes a default boundary config to `$HOME/.coder-modules/coder/boundary/config/config.yaml` (customizable)
15+
- Installs agent-firewall (via coder subcommand, direct installation, or compilation from source)
16+
- Creates a wrapper script at `$HOME/.coder-modules/coder/agent-firewall/scripts/agent-firewall-wrapper.sh`
17+
- Writes a [default agent-firewall config](./config.yaml.tftpl) to `$HOME/.coder-modules/coder/agent-firewall/config/config.yaml` (customizable)
1818
- Provides the wrapper path, config path, and script names via outputs
1919
- Uses coder-utils and output `scripts` for synchronization. https://registry.coder.com/modules/coder/coder-utils?tab=outputs
2020

2121
```tf
22-
module "boundary" {
23-
source = "registry.coder.com/coder/boundary/coder"
22+
module "agent-firewall" {
23+
source = "registry.coder.com/coder/agent-firewall/coder"
2424
version = "0.0.1"
2525
agent_id = coder_agent.main.id
2626
}
2727
```
2828

2929
## Examples
3030

31-
Use the `boundary_wrapper_path` output to access the wrapper path and `boundary_config_path` to access config path in Terraform and pass it to scripts that should run commands in network isolation.
31+
Use the `agent_firewall_wrapper_path` output to access the wrapper path and `agent_firewall_config_path` to access config path in Terraform and pass it to scripts that should run commands in network isolation.
3232

3333
### With Claude Code
3434

35-
Use boundary alongside the `claude-code` module to run Claude in a
35+
Use agent-firewall alongside the `claude-code` module to run Claude in a
3636
network-isolated environment.
3737

3838
#### As an automated task
3939

4040
```tf
41-
module "boundary" {
42-
source = "registry.coder.com/coder/boundary/coder"
41+
module "agent-firewall" {
42+
source = "registry.coder.com/coder/agent-firewall/coder"
4343
version = "0.0.1"
4444
agent_id = coder_agent.main.id
4545
}
4646
47-
resource "coder_script" "claude_with_boundary" {
47+
resource "coder_script" "claude_with_agent_firewall" {
4848
agent_id = coder_agent.main.id
49-
display_name = "Claude (Boundary)"
49+
display_name = "Claude (Agent Firewall)"
5050
run_on_start = true
5151
script = <<-EOT
5252
#!/bin/bash
5353
set -e
54-
coder exp sync want claude-boundary \
55-
${join(" ", module.boundary.scripts)} \
54+
coder exp sync want claude-agent-firewall \
55+
${join(" ", module.agent-firewall.scripts)} \
5656
${join(" ", module.claude-code.scripts)}
57-
coder exp sync start claude-boundary
58-
"${module.boundary.boundary_wrapper_path}" --config="${module.boundary.boundary_config_path}" -- claude -p "Fix issue #840 from coder/coder"
57+
coder exp sync start claude-agent-firewall
58+
"${module.agent-firewall.agent_firewall_wrapper_path}" --config="${module.agent-firewall.agent_firewall_config_path}" -- claude -p "Fix issue #840 from coder/coder"
5959
EOT
6060
}
6161
```
6262

6363
#### As a Coder app
6464

6565
```tf
66-
module "boundary" {
67-
source = "registry.coder.com/coder/boundary/coder"
66+
module "agent-firewall" {
67+
source = "registry.coder.com/coder/agent-firewall/coder"
6868
version = "0.0.1"
6969
agent_id = coder_agent.main.id
7070
}
7171
72-
resource "coder_app" "claude_with_boundary" {
72+
resource "coder_app" "claude_with_agent_firewall" {
7373
agent_id = coder_agent.main.id
7474
display_name = "Claude Code"
7575
slug = "claude-code"
7676
command = <<-EOT
7777
#!/bin/bash
7878
set -e
7979
exec tmux new-session -A -s claude-code \
80-
'"${module.boundary.boundary_wrapper_path}" --config="${module.boundary.boundary_config_path}" -- claude'
80+
'"${module.agent-firewall.agent_firewall_wrapper_path}" --config="${module.agent-firewall.agent_firewall_config_path}" -- claude'
8181
EOT
8282
}
8383
```
@@ -93,26 +93,26 @@ The Coder deployment domain is automatically added to the allowlist using
9393
`data.coder_workspace.me.access_url`.
9494

9595
By default the config is written to
96-
`$HOME/.coder-modules/coder/boundary/config/config.yaml`. You can
97-
access the resolved path via the `boundary_config_path` output. Override
96+
`$HOME/.coder-modules/coder/agent-firewall/config/config.yaml`. You can
97+
access the resolved path via the `agent_firewall_config_path` output. Override
9898
it in two ways:
9999

100100
### Inline config
101101

102102
Pass the full YAML content directly:
103103

104104
```tf
105-
module "boundary" {
106-
source = "registry.coder.com/coder/boundary/coder"
105+
module "agent-firewall" {
106+
source = "registry.coder.com/coder/agent-firewall/coder"
107107
version = "0.0.1"
108108
agent_id = coder_agent.main.id
109109
110-
boundary_config = <<-YAML
110+
agent_firewall_config = <<-YAML
111111
allowlist:
112112
- domain=your-deployment.coder.com
113113
- domain=api.anthropic.com
114114
- domain=api.openai.com
115-
log_dir: /tmp/boundary_logs
115+
log_dir: /tmp/agent_firewall_logs
116116
proxy_port: 8087
117117
log_level: warn
118118
YAML
@@ -122,25 +122,25 @@ module "boundary" {
122122
### External config file
123123

124124
Point to an existing config file in the workspace. The module will not
125-
write any config and the `boundary_config_path` output will point to
126-
your path:
125+
write any config and the `agent_firewall_config_path` output will point to
126+
your path. The file must exist on disk before agent-firewall starts.
127127

128128
```tf
129-
module "boundary" {
130-
source = "registry.coder.com/coder/boundary/coder"
129+
module "agent-firewall" {
130+
source = "registry.coder.com/coder/agent-firewall/coder"
131131
version = "0.0.1"
132132
agent_id = coder_agent.main.id
133133
134-
boundary_config_path = "/workspace/my-boundary-config.yaml"
134+
agent_firewall_config_path = "/workspace/my-agent-firewall-config.yaml"
135135
}
136136
```
137137

138-
> **Note:** `boundary_config` and `boundary_config_path` are mutually
138+
> **Note:** `agent_firewall_config` and `agent_firewall_config_path` are mutually
139139
> exclusive, setting both produces a validation error.
140140
141141
See the [Agent Firewall docs](https://coder.com/docs/ai-coder/agent-firewall)
142142
for the full config reference.
143143

144144
## References
145145

146-
- [Boundary Documentation](https://coder.com/docs/ai-coder/agent-firewall)
146+
- [Agent Firewall Documentation](https://coder.com/docs/ai-coder/agent-firewall)
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Test for agent-firewall module
2+
3+
run "plan_with_required_vars" {
4+
command = plan
5+
6+
variables {
7+
agent_id = "test-agent-id"
8+
}
9+
10+
# Verify the agent_firewall_wrapper_path output
11+
assert {
12+
condition = output.agent_firewall_wrapper_path == "$HOME/.coder-modules/coder/agent-firewall/scripts/agent-firewall-wrapper.sh"
13+
error_message = "agent_firewall_wrapper_path output should be correct"
14+
}
15+
16+
# Verify agent_firewall_config_path output defaults to the managed path
17+
assert {
18+
condition = output.agent_firewall_config_path == "$HOME/.coder-modules/coder/agent-firewall/config/config.yaml"
19+
error_message = "agent_firewall_config_path output should default to managed config path"
20+
}
21+
22+
# Verify the scripts output contains the install script name
23+
assert {
24+
condition = contains(output.scripts, "coder-agent-firewall-install_script")
25+
error_message = "scripts should contain the install script name"
26+
}
27+
}
28+
29+
run "plan_with_compile_from_source" {
30+
command = plan
31+
32+
variables {
33+
agent_id = "test-agent-id"
34+
compile_agent_firewall_from_source = true
35+
agent_firewall_version = "main"
36+
}
37+
38+
assert {
39+
condition = output.agent_firewall_wrapper_path == "$HOME/.coder-modules/coder/agent-firewall/scripts/agent-firewall-wrapper.sh"
40+
error_message = "agent_firewall_wrapper_path output should be correct"
41+
}
42+
43+
assert {
44+
condition = contains(output.scripts, "coder-agent-firewall-install_script")
45+
error_message = "scripts should contain the install script name"
46+
}
47+
}
48+
49+
run "plan_with_use_directly" {
50+
command = plan
51+
52+
variables {
53+
agent_id = "test-agent-id"
54+
use_agent_firewall_directly = true
55+
agent_firewall_version = "latest"
56+
}
57+
58+
assert {
59+
condition = output.agent_firewall_wrapper_path == "$HOME/.coder-modules/coder/agent-firewall/scripts/agent-firewall-wrapper.sh"
60+
error_message = "agent_firewall_wrapper_path output should be correct"
61+
}
62+
63+
assert {
64+
condition = contains(output.scripts, "coder-agent-firewall-install_script")
65+
error_message = "scripts should contain the install script name"
66+
}
67+
}
68+
69+
run "plan_with_custom_hooks" {
70+
command = plan
71+
72+
variables {
73+
agent_id = "test-agent-id"
74+
pre_install_script = "echo 'Before install'"
75+
post_install_script = "echo 'After install'"
76+
}
77+
78+
assert {
79+
condition = contains(output.scripts, "coder-agent-firewall-install_script")
80+
error_message = "scripts should contain the install script name"
81+
}
82+
83+
# Verify pre and post install script names are set
84+
assert {
85+
condition = contains(output.scripts, "coder-agent-firewall-pre_install_script")
86+
error_message = "scripts should contain the pre_install script name"
87+
}
88+
89+
assert {
90+
condition = contains(output.scripts, "coder-agent-firewall-post_install_script")
91+
error_message = "scripts should contain the post_install script name"
92+
}
93+
}
94+
95+
run "plan_with_custom_module_directory" {
96+
command = plan
97+
98+
variables {
99+
agent_id = "test-agent-id"
100+
module_directory = "$HOME/.coder-modules/custom/agent-firewall"
101+
}
102+
103+
assert {
104+
condition = output.agent_firewall_wrapper_path == "$HOME/.coder-modules/custom/agent-firewall/scripts/agent-firewall-wrapper.sh"
105+
error_message = "agent_firewall_wrapper_path output should use custom module directory"
106+
}
107+
108+
# Config path should also follow the module directory
109+
assert {
110+
condition = output.agent_firewall_config_path == "$HOME/.coder-modules/custom/agent-firewall/config/config.yaml"
111+
error_message = "agent_firewall_config_path output should use custom module directory"
112+
}
113+
}
114+
115+
run "plan_with_inline_config" {
116+
command = plan
117+
118+
variables {
119+
agent_id = "test-agent-id"
120+
agent_firewall_config = "allowlist:\n - domain=example.com\nlog_level: debug\n"
121+
}
122+
123+
# Inline config should still point to the managed path.
124+
assert {
125+
condition = output.agent_firewall_config_path == "$HOME/.coder-modules/coder/agent-firewall/config/config.yaml"
126+
error_message = "agent_firewall_config_path output should point to managed config path"
127+
}
128+
}
129+
130+
run "plan_with_config_path" {
131+
command = plan
132+
133+
variables {
134+
agent_id = "test-agent-id"
135+
agent_firewall_config_path = "/workspace/my-boundary-config.yaml"
136+
}
137+
138+
# agent_firewall_config_path output should point to the user-provided path.
139+
assert {
140+
condition = output.agent_firewall_config_path == "/workspace/my-boundary-config.yaml"
141+
error_message = "agent_firewall_config_path output should point to user-provided path"
142+
}
143+
}
144+
145+
run "plan_with_both_configs_should_fail" {
146+
command = plan
147+
148+
variables {
149+
agent_id = "test-agent-id"
150+
agent_firewall_config = "allowlist: []"
151+
agent_firewall_config_path = "/workspace/config.yaml"
152+
}
153+
154+
expect_failures = [
155+
var.agent_firewall_config,
156+
]
157+
}

0 commit comments

Comments
 (0)