Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit bf9439b

Browse files
ryanuberclaire-tfcBrianMMcClain
authored
Request forwarding docs (#93)
* Updating index * Update requirements * Add optional request forwarding configuration * Add initial request forwarding page * Add required agent version * Mention HTTP CONNECT * Add security section * Fix memory recommendation * Adding blurbs for timeouts and monitoring * Apply suggestions from code review Co-authored-by: Claire Knutson <117297128+clairevnext@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Claire Knutson <117297128+clairevnext@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Brian McClain <brianmmcclain@gmail.com> * Update website/docs/cloud-docs/agents/agents.mdx Co-authored-by: Brian McClain <brianmmcclain@gmail.com> * Update website/docs/cloud-docs/agents/agents.mdx Co-authored-by: Brian McClain <brianmmcclain@gmail.com> * Update website/docs/cloud-docs/agents/request-forwarding.mdx Co-authored-by: Brian McClain <brianmmcclain@gmail.com> * Update website/docs/cloud-docs/agents/request-forwarding.mdx Co-authored-by: Brian McClain <brianmmcclain@gmail.com> * Add missing link --------- Co-authored-by: Claire Knutson <117297128+clairevnext@users.noreply.github.com> Co-authored-by: Brian McClain <brianmmcclain@gmail.com>
1 parent b9eabad commit bf9439b

File tree

6 files changed

+124
-20
lines changed

6 files changed

+124
-20
lines changed

website/data/cloud-docs-agents-nav-data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{ "title": "Install and Run Agents", "path": "agents" },
88
{ "title": "Inject Custom Run Actions (Hooks)", "path": "hooks" },
99
{ "title": "Manage Agent Pools", "path": "agent-pools" },
10+
{ "title": "Request Forwarding", "path": "request-forwarding" },
1011
{ "title": "Telemetry", "path": "telemetry" },
1112
{ "title": "Logging", "path": "logging" },
1213
{ "title": "Metrics", "path": "metrics" },

website/docs/cloud-docs/agents/agents.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ You can also configure the agent to run in single-execution mode, which ensures
8989

9090
To use single-execution mode, start the agent with the `-single` command line argument.
9191

92+
### Optional Configuration: Request Forwarding
93+
94+
You can configure the agent to accept forwarded requests from Terraform Cloud. Request forwarding enables Terraform Cloud to securely access private infrastructure resources, such as private VCS systems. See [Request Forwarding](/terraform/cloud-docs/agents/request-forwarding) for more details. By default, request forwarding is disabled. To enable it, start the agent with the `-request-forwarding` command line argument.
95+
96+
Agents handle forwarded requests separately from other workloads and may process requests in parallel to plans, applies, policy checks, etc. You can modify this behavior by enabling or disabling certain workload types via the `-accept` parameter, and selectively setting the `-request-forwarding` flag on certain agent(s) only. For example, you may have a pool of 4 agents, where two are configured to handle only plans and applies, and the other two are configured to handle only request forwarding.
97+
9298
## Stop the Agent
9399

94100
~> **Important:** We strongly recommend that you only terminate the agent using one of these methods. Abruptly terminating an agent by forcefully stopping the process or power cycling the host does not let the agent deregister and results in an **Unknown** agent status. Abrupt termination may cause further capacity issues. Refer to [capacity issues](/terraform/cloud-docs/agents/agent-pools#agent-capacity-usage) for details.

website/docs/cloud-docs/agents/index.mdx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,9 @@ description: >-
1313

1414
Terraform Cloud Agents allow Terraform Cloud to communicate with isolated, private, or on-premises infrastructure. By deploying lightweight agents within a specific network segment, you can establish a simple connection between your environment and Terraform Cloud which allows for provisioning operations and management. This is useful for on-premises infrastructure types such as vSphere, Nutanix, OpenStack, enterprise networking providers, and anything you might have in a protected enclave.
1515

16-
The agent architecture is pull-based, so no inbound connectivity is required. Any agent you provision will poll Terraform Cloud for work and carry out execution of that work locally.
16+
The agent only requires outbound connectivity to Terraform Cloud, enabling private networks to remain secure and typically requiring no special networking configuration or exceptions.
1717

1818
## Terraform Enterprise
1919

2020
Terraform Enterprise supports Terraform Cloud Agents. Refer to
2121
[Terraform Cloud Agents on TFE](/terraform/enterprise/application-administration/agents-on-tfe) for Terraform Enterprise specific documentation and requirements.
22-
23-
## Limitations
24-
25-
Agents allow you to run Terraform operations from a Terraform Cloud workspace on your private infrastructure. Agents do not support:
26-
27-
- Connecting to private infrastructure from Sentinel policies using the [http import](https://docs.hashicorp.com/sentinel/imports/http).
28-
- Connecting Terraform Cloud workspaces to VCS instances that do not allow access from the public internet. For example, you cannot use agents to connect to a GitHub Enterprise Server instance that requires access to your VPN.
29-
30-
For these use cases, we recommend you leverage the information provided by the [IP Ranges documentation](/terraform/cloud-docs/architectural-details/ip-ranges) to permit direct communication from the appropriate Terraform Cloud service to your internal infrastructure.
31-
32-
33-
34-
35-
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
page_title: Terraform Cloud Agents - Request Forwarding
3+
description: >-
4+
Access private network resources using agents with request forwarding.
5+
---
6+
7+
# Request Forwarding
8+
9+
You can configure Terraform Cloud Agents to handle HTTP and HTTPS
10+
request forwarding on behalf of Terraform Cloud. This enables Terraform Cloud to access
11+
services in private networks without requiring direct inbound network access.
12+
13+
Only specific features and use cases will use agent request forwarding to
14+
fulfill requests.
15+
16+
-> **Note:** Refer to [Terraform Cloud pricing](https://www.hashicorp.com/products/terraform/pricing) for details on which features can use request forwarding.
17+
18+
## Request Forwarding Architecture
19+
20+
Request forwarding is an additional function that you can enable on a per-agent
21+
basis. Agents are deployed into private networks where they have direct access
22+
to the target private services, such as private version control systems or other APIs.
23+
Agents register with Terraform Cloud via outbound-only connections. Terraform Cloud
24+
holds these connections open and uses them to transmit requests and responses
25+
between the target API and Terraform Cloud.
26+
27+
![Request forwarding architecture diagram](/img/request-forwarding-arch.png)
28+
29+
## Forwarded Request Routing
30+
31+
Request forwarding requires the use of [agent pools](/terraform/cloud-docs/agents/agent-pools).
32+
Each agent pool may have multiple agents registered with request forwarding enabled. The agent pool is
33+
then selected by the user in Terraform Cloud as the target for various features
34+
which require access to private network resources. This creates the mapping from
35+
Terraform Cloud resources (such as VCS connections) to a pool of agents capable
36+
of accessing the target API.
37+
38+
## Agent Configuration
39+
40+
To enable request forwarding, start the agent with the `-request-forwarding`
41+
flag, or set the environment variable `TFC_AGENT_REQUEST_FORWARDING=true`. When
42+
the agent starts, you will see the following log messages:
43+
44+
```
45+
[INFO] core: Request forwarding is enabled
46+
[INFO] grpc_connector: Connected to broker, awaiting requests
47+
```
48+
49+
These log messages indicate that the agent has successfully connected to Terraform Cloud
50+
and is ready to start forwarding requests.
51+
52+
## Requirements and Limitations
53+
54+
Agent version 1.15.0+ is required to use request forwarding.
55+
56+
We recommend that you allocate at least 250MB of additional system memory specifically
57+
for request forwarding. This is in addition to the minimum
58+
[system requirements](/terraform/cloud-docs/agents/requirements).
59+
60+
Forwarded requests are limited to a 10MB response body. This limit comfortably
61+
supports all Terraform Cloud operations while providing protection against
62+
unbounded responses.
63+
64+
All forwarded requests are subject to a request timeout. The default timeout is
65+
60 seconds, but this value is tuned for specific features and use cases and may
66+
be set slightly higher or lower depending on the type of request being made.
67+
68+
Agents must be able to connect to Terraform Cloud outbound over the internet, as
69+
well as to private infrastructure targets for request forwarding via HTTP and HTTPS.
70+
71+
## Performance and Scaling
72+
73+
Each agent may handle multiple requests simultaneously. In many cases, a single
74+
agent may provide sufficient throughput to handle all forwarded requests. It is
75+
recommended that 2 or more agents with request forwarding enabled are deployed
76+
for each pool which will leverage request forwarding features. Running multiple
77+
request forwarding agents provides better fault tolerance and distribution of
78+
requests.
79+
80+
We recommend that you monitor the memory and CPU utilization on your agents with
81+
request forwarding enabled to determine if you need to deploy additional agents. Refer to
82+
[runtime metrics](/terraform/cloud-docs/agents/metrics#runtime-metrics) for more details.
83+
84+
Since an agent may handle more than one forwarded request simultaneously, both horizontal
85+
(number of agents) and vertical (system resources per agent host) scaling vectors are important.
86+
87+
## Egress Proxy Support
88+
89+
If your agents require an egress proxy to reach Terraform Cloud over the internet, you can set the
90+
`HTTPS_PROXY` environment variable with your proxy's address when starting the agent. Your
91+
proxy software must support the [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT) protocol,
92+
which the agent will use to establish a secure tunnel through the proxy to Terraform Cloud.
93+
94+
## Security considerations
95+
96+
The agent application secures forwarded requests by ensuring that requests may
97+
only be forwarded through the agent which originate from Terraform Cloud. The agent
98+
guarantees this by requiring an authenticated session to be established prior to forwarding any requests.
99+
100+
Because forwarded requests and responses may contain sensitive information,
101+
such as API tokens to 3rd party vendors and PII, we recommend
102+
that production use cases use dedicated agents to handle request
103+
forwarding functionality. This ensures that no other processes executing user
104+
code will be running within the same process space and avoids certain
105+
attack vectors.
106+
107+
To dedicate an agent to request forwarding only, set the [accepted
108+
workload types](/terraform/cloud-docs/agents/agents#accept) to `none`. This
109+
disables all workloads except for request forwarding from being executed.

website/docs/cloud-docs/agents/requirements.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ description: >-
99

1010
Ensure your system meets the following requirements before installing and configuring Terraform Cloud Agents. Refer to [Terraform Cloud Agents on TFE](/terraform/enterprise/admin/agents-on-tfe) for additional Terraform Enterprise requirements.
1111

12-
1312
## Supported Operating Systems
1413

1514
[Agents](https://releases.hashicorp.com/tfc-agent/) currently only support x86_64 bit Linux operating systems. You can also run the agent within Docker using our official [Terraform Cloud Agent Docker container](https://hub.docker.com/r/hashicorp/tfc-agent).
@@ -20,24 +19,27 @@ Agents support Terraform versions 0.12 and above. Workspaces configured to use T
2019

2120
## Hardware Requirements
2221

23-
The host running the agent has varying resource requirements depending on the workspace. A host can be a dedicated or shared cloud instance, virtual machine, bare metal server, or a container. You should monitor and adjust memory, CPU, and disk space based on each workspace's usage and performance. The name of your instance type may vary depending on your deployment environment.
22+
The host running the agent has varying resource requirements depending on the workspaces the agent will serve and the agent's configuration. A host can be a dedicated or shared cloud instance, virtual machine, bare metal server, or a container. You should monitor and adjust memory, CPU, and disk space based on each workspace's usage and performance.
2423

2524
Use the following specifications as a reference:
2625

2726
- At least 4GB of free disk space
2827
- Each run requires the agent to temporarily store local copies of the tarred repository, extracted repository, state file, any providers or modules, and the Terraform binary itself.
28+
- When using agents for private VCS operations, we recommend that the agent has storage capacity equal to at least twice the maximum expected repository size.
2929
- At least 2GB of system memory
30+
- This provides the agent with enough memory to complete run operations, such as `terraform plan`, `git clone`, and `sentinel apply`. This also supports operations such as uploading and downloading artifacts, constructing temporary execution environments, and parsing configurations.
31+
- If you enable request forwarding, we recommend that you add at least 250MB of additional memory. The agent may hold multiple forwarded requests and responses in memory until they are successfully executed and relayed to Terraform Cloud.
3032

3133
## Networking Requirements
3234

33-
In order for an agent to function properly, it must be able to make outbound requests over HTTPS (TCP port 443) to the Terraform Cloud application APIs. These requests may require perimeter networking as well as container host networking changes, depending on your environment. Refer to the [Terraform Cloud IP Ranges documentation](/terraform/cloud-docs/architectural-details/ip-ranges) for more details on the IP ranges.
35+
In order for an agent to function properly, it must be able to make outbound TCP connections to the Terraform Cloud application APIs. These requests may require perimeter networking as well as container host networking changes, depending on your environment. Refer to the [Terraform Cloud IP Ranges documentation](/terraform/cloud-docs/architectural-details/ip-ranges) for more details on the IP ranges.
3436

35-
Additionally, the agent must also be able to communicate with any services required by the Terraform code it is executing. This includes the Terraform releases distribution service, [releases.hashicorp.com](https://releases.hashicorp.com) (supported by [Fastly](https://api.fastly.com/public-ip-list)), as well as any provider APIs. The following services run on these IP ranges:
37+
Additionally, the agent must also be able to communicate with any services required by the Terraform code it is executing. This includes the Terraform releases distribution service, [releases.hashicorp.com](https://releases.hashicorp.com), as well as any provider APIs. The following services run on these IP ranges:
3638

3739
| Hostname | Port/Protocol | Directionality | Purpose |
3840
| ---------------------- | -------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
3941
| app.terraform.io | tcp/443, HTTPS | Outbound | Polling for new workloads, providing status updates, and downloading private modules from Terraform Cloud's Private Module Registry |
4042
| registry.terraform.io | tcp/443, HTTPS | Outbound | Downloading public modules from the Terraform Registry |
4143
| releases.hashicorp.com | tcp/443, HTTPS | Outbound | Updating agent components and downloading Terraform binaries |
4244
| archivist.terraform.io | tcp/443, HTTPS | Outbound | Blob Storage |
43-
45+
| agents.terraform.io | tcp/7146, TCP | Outbound | Agent RPC interface (currently used for request forwarding only) |
20.5 KB
Loading

0 commit comments

Comments
 (0)