Skip to content

Commit ad96099

Browse files
Merge 'feat/add-http-proxy' into 'main'
feat: add HTTP proxy support See merge request: !92
2 parents 592e4d1 + 79e05c7 commit ad96099

8 files changed

Lines changed: 1209 additions & 36 deletions

File tree

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,61 @@ $ export VOLCENGINE_PROFILE="your_profile"
142142
$ export VOLCENGINE_FILE_PATH="your_file_path" # if empty, default path is ~/.volcengine
143143
```
144144

145+
## Authenticated Cloud Control proxy
146+
147+
Use `proxy_url` together with `proxy_authorization` when Cloud Control API requests must pass through an authenticated HTTP proxy. `proxy_authorization` is the complete value of the `Proxy-Authorization` header and is marked sensitive. For HTTP proxies, keep credentials out of `proxy_url` and use this attribute instead. `proxy_authorization` supports HTTP and HTTPS proxy URLs; SOCKS5 and SOCKS5H URLs remain available without this attribute.
148+
149+
For a ZTI proxy, configure the same values used by curl:
150+
151+
```shell
152+
PSM="<your-psm>"
153+
PROXY="<your-proxy-domain>"
154+
AUTH_TOKEN=$(echo -n "ZTI_$PSM:$(cat "$SEC_TOKEN_PATH")" | base64 -w0)
155+
156+
export VOLCENGINE_PROXY_URL="http://${PROXY}:8080"
157+
export VOLCENGINE_PROXY_AUTHORIZATION="Basic ${AUTH_TOKEN}"
158+
```
159+
160+
The equivalent Terraform configuration is:
161+
162+
```hcl
163+
variable "proxy_authorization" {
164+
type = string
165+
sensitive = true
166+
}
167+
168+
provider "volcenginecc" {
169+
proxy_url = "http://<your-proxy-domain>:8080"
170+
proxy_authorization = var.proxy_authorization
171+
}
172+
```
173+
174+
Standard `no_proxy` rules identify destinations that connect directly instead of using `proxy_url`:
175+
176+
```hcl
177+
provider "volcenginecc" {
178+
proxy_url = "http://<your-proxy-domain>:8080"
179+
proxy_authorization = var.proxy_authorization
180+
no_proxy = "localhost,127.0.0.1,.internal.example.com"
181+
}
182+
```
183+
184+
To use the proxy only for specified destinations, configure the inverse allowlist with `proxy_include_domains`:
185+
186+
```hcl
187+
provider "volcenginecc" {
188+
proxy_url = "http://<your-proxy-domain>:8080"
189+
proxy_authorization = var.proxy_authorization
190+
proxy_include_domains = [
191+
"cloudcontrol.cn-beijing.volcengineapi.com",
192+
]
193+
}
194+
```
195+
196+
Replace `cn-beijing` with the configured region, or list the host from `endpoints.cloudcontrolapi` when using a custom endpoint. A domain without a leading dot matches the domain and its subdomains; a leading dot matches subdomains only. IP addresses, CIDR ranges, optional ports, and `*` follow standard `NO_PROXY` matching. `no_proxy` and `proxy_include_domains` cannot be configured together.
197+
198+
The equivalent environment variables are `VOLCENGINE_NO_PROXY` (with `NO_PROXY` and `no_proxy` as fallbacks) and comma-separated `VOLCENGINE_PROXY_INCLUDE_DOMAINS`. Explicit provider attributes take precedence over the environment variables. These settings apply to Cloud Control API traffic; STS calls made by `assume_role` use a separate client.
199+
145200
<!-- schema generated by tfplugindocs -->
146201

147202
## Schema
@@ -156,7 +211,10 @@ $ export VOLCENGINE_FILE_PATH="your_file_path" # if empty, default path is ~/.vo
156211
- `customer_headers` (String) CUSTOMER HEADERS for Volcengine Provider. The customer_headers field uses commas (,) to separate multiple headers, and colons (:) to separate each header key from its corresponding value.
157212
- `disable_ssl` (Boolean) Disable SSL for Volcengine Provider
158213
- `endpoints` (Attributes) An `endpoints` block (documented below). Only one `endpoints` block may be in the configuration. (see [below for nested schema](#nestedatt--endpoints))
159-
- `proxy_url` (String) PROXY URL for Volcengine Provider
214+
- `no_proxy` (String) Comma-separated hosts, domain suffixes, IP addresses, or CIDR ranges that bypass proxy_url. It follows standard NO_PROXY matching and can be sourced from VOLCENGINE_NO_PROXY, NO_PROXY, or no_proxy.
215+
- `proxy_authorization` (String, Sensitive) Value of the Proxy-Authorization header for Cloud Control API proxy requests, for example `Basic <token>`. It can also be sourced from the `VOLCENGINE_PROXY_AUTHORIZATION` environment variable.
216+
- `proxy_include_domains` (Set of String) Hosts, domain suffixes, IP addresses, or CIDR ranges that use proxy_url while all other destinations connect directly. It can be sourced as a comma-separated list from VOLCENGINE_PROXY_INCLUDE_DOMAINS and cannot be combined with no_proxy.
217+
- `proxy_url` (String) HTTP, HTTPS, SOCKS5, or SOCKS5H proxy URL for Cloud Control API requests. It can also be sourced from the `VOLCENGINE_PROXY_URL` environment variable.
160218
- `region` (String) The Region for Volcengine Provider. It must be provided, but it can also be sourced from the `VOLCENGINE_REGION` environment variable
161219

162220

docs/index.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,61 @@ $ export VOLCENGINE_PROFILE="your_profile"
137137
$ export VOLCENGINE_FILE_PATH="your_file_path" # if empty, default path is ~/.volcengine
138138
```
139139

140+
## Authenticated Cloud Control proxy
141+
142+
Use `proxy_url` together with `proxy_authorization` when Cloud Control API requests must pass through an authenticated HTTP proxy. `proxy_authorization` is the complete value of the `Proxy-Authorization` header and is marked sensitive. For HTTP proxies, keep credentials out of `proxy_url` and use this attribute instead. `proxy_authorization` supports HTTP and HTTPS proxy URLs; SOCKS5 and SOCKS5H URLs remain available without this attribute.
143+
144+
For a ZTI proxy, configure the same values used by curl:
145+
146+
```shell
147+
PSM="<your-psm>"
148+
PROXY="<your-proxy-domain>"
149+
AUTH_TOKEN=$(echo -n "ZTI_$PSM:$(cat "$SEC_TOKEN_PATH")" | base64 -w0)
150+
151+
export VOLCENGINE_PROXY_URL="http://${PROXY}:8080"
152+
export VOLCENGINE_PROXY_AUTHORIZATION="Basic ${AUTH_TOKEN}"
153+
```
154+
155+
The equivalent Terraform configuration is:
156+
157+
```hcl
158+
variable "proxy_authorization" {
159+
type = string
160+
sensitive = true
161+
}
162+
163+
provider "volcenginecc" {
164+
proxy_url = "http://<your-proxy-domain>:8080"
165+
proxy_authorization = var.proxy_authorization
166+
}
167+
```
168+
169+
Standard `no_proxy` rules identify destinations that connect directly instead of using `proxy_url`:
170+
171+
```hcl
172+
provider "volcenginecc" {
173+
proxy_url = "http://<your-proxy-domain>:8080"
174+
proxy_authorization = var.proxy_authorization
175+
no_proxy = "localhost,127.0.0.1,.internal.example.com"
176+
}
177+
```
178+
179+
To use the proxy only for specified destinations, configure the inverse allowlist with `proxy_include_domains`:
180+
181+
```hcl
182+
provider "volcenginecc" {
183+
proxy_url = "http://<your-proxy-domain>:8080"
184+
proxy_authorization = var.proxy_authorization
185+
proxy_include_domains = [
186+
"cloudcontrol.cn-beijing.volcengineapi.com",
187+
]
188+
}
189+
```
190+
191+
Replace `cn-beijing` with the configured region, or list the host from `endpoints.cloudcontrolapi` when using a custom endpoint. A domain without a leading dot matches the domain and its subdomains; a leading dot matches subdomains only. IP addresses, CIDR ranges, optional ports, and `*` follow standard `NO_PROXY` matching. `no_proxy` and `proxy_include_domains` cannot be configured together.
192+
193+
The equivalent environment variables are `VOLCENGINE_NO_PROXY` (with `NO_PROXY` and `no_proxy` as fallbacks) and comma-separated `VOLCENGINE_PROXY_INCLUDE_DOMAINS`. Explicit provider attributes take precedence over the environment variables. These settings apply to Cloud Control API traffic; STS calls made by `assume_role` use a separate client.
194+
140195
<!-- schema generated by tfplugindocs -->
141196

142197
## Schema
@@ -152,7 +207,10 @@ $ export VOLCENGINE_FILE_PATH="your_file_path" # if empty, default path is ~/.vo
152207
- `customer_headers` (String) CUSTOMER HEADERS for Volcengine Provider. The customer_headers field uses commas (,) to separate multiple headers, and colons (:) to separate each header key from its corresponding value.
153208
- `disable_ssl` (Boolean) Disable SSL for Volcengine Provider
154209
- `endpoints` (Attributes) An `endpoints` block (documented below). Only one `endpoints` block may be in the configuration. (see [below for nested schema](#nestedatt--endpoints))
155-
- `proxy_url` (String) PROXY URL for Volcengine Provider
210+
- `no_proxy` (String) Comma-separated hosts, domain suffixes, IP addresses, or CIDR ranges that bypass proxy_url. It follows standard NO_PROXY matching and can be sourced from VOLCENGINE_NO_PROXY, NO_PROXY, or no_proxy.
211+
- `proxy_authorization` (String, Sensitive) Value of the Proxy-Authorization header for Cloud Control API proxy requests, for example `Basic <token>`. It can also be sourced from the `VOLCENGINE_PROXY_AUTHORIZATION` environment variable.
212+
- `proxy_include_domains` (Set of String) Hosts, domain suffixes, IP addresses, or CIDR ranges that use proxy_url while all other destinations connect directly. It can be sourced as a comma-separated list from VOLCENGINE_PROXY_INCLUDE_DOMAINS and cannot be combined with no_proxy.
213+
- `proxy_url` (String) HTTP, HTTPS, SOCKS5, or SOCKS5H proxy URL for Cloud Control API requests. It can also be sourced from the `VOLCENGINE_PROXY_URL` environment variable.
156214
- `region` (String) The Region for Volcengine Provider. It must be provided, but it can also be sourced from the `VOLCENGINE_REGION` environment variable
157215

158216

@@ -185,4 +243,4 @@ The current version has a known issue when modifying the SetNestedAttribute and
185243
| Parameter Type | Impact | Recommendation | Example |
186244
|---|---|---|---|
187245
| `SetNestedAttribute` | If `SetNestedAttribute` is not fully defined, creating new resources may fail. Even when it is fully defined, modifying existing items in the Set may cause the following issues: errors that prevent the update; or no explicit error, but non-target items being incorrectly updated. There is also a certain probability that re-running `terraform apply` will fail. | 1. All attributes under `SetNestedAttribute` must be fully defined.<br>2. If there are multiple items under a `SetNestedAttribute`, try to avoid operating on them through Terraform. | 1. [`volcenginecc_alb_listener`: `domain_extensions`](https://registry.terraform.io/providers/volcengine/volcenginecc/latest/docs/resources/alb_listener)<br>2. [`volcenginecc_alb_rule`: `rule_action`](https://registry.terraform.io/providers/volcengine/volcenginecc/latest/docs/resources/alb_rule) |
188-
| `ListNestedAttribute` | When it contains read-only attributes, it has no impact on creating new resources or modifying existing ones. However, when changing resource data, inserting or deleting items in the middle of the list can lead to data being misaligned, causing incorrect updates to non-target items. | 1. All attributes under `ListNestedAttribute` must be fully defined.<br>2. If there are multiple items under a `ListNestedAttribute`, try to avoid operating on them through Terraform.<br>3. If changes are necessary, only add or delete items at the end of the `ListNestedAttribute`. | 1. [`volcenginecc_rdspostgresql_db_endpoint`: `addresses`](https://registry.terraform.io/providers/volcengine/volcenginecc/latest/docs/rdspostgresql_db_endpoint)<br>2. [`volcenginecc_ecs_instance`: `secondary_network_interfaces`](https://registry.terraform.io/providers/volcengine/volcenginecc/latest/docs/ecs_instance) |
246+
| `ListNestedAttribute` | When it contains read-only attributes, it has no impact on creating new resources or modifying existing ones. However, when changing resource data, inserting or deleting items in the middle of the list can lead to data being misaligned, causing incorrect updates to non-target items. | 1. All attributes under `ListNestedAttribute` must be fully defined.<br>2. If there are multiple items under a `ListNestedAttribute`, try to avoid operating on them through Terraform.<br>3. If changes are necessary, only add or delete items at the end of the `ListNestedAttribute`. | 1. [`volcenginecc_rdspostgresql_db_endpoint`: `addresses`](https://registry.terraform.io/providers/volcengine/volcenginecc/latest/docs/rdspostgresql_db_endpoint)<br>2. [`volcenginecc_ecs_instance`: `secondary_network_interfaces`](https://registry.terraform.io/providers/volcengine/volcenginecc/latest/docs/ecs_instance) |

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
github.com/test-go/testify v1.1.4
2020
github.com/volcengine/volcengine-go-sdk v1.2.36
2121
github.com/xeipuuv/gojsonschema v1.2.0
22+
golang.org/x/net v0.52.0
2223
golang.org/x/text v0.36.0
2324
)
2425

@@ -80,7 +81,6 @@ require (
8081
github.com/zclconf/go-cty v1.18.1 // indirect
8182
golang.org/x/crypto v0.49.0 // indirect
8283
golang.org/x/mod v0.35.0 // indirect
83-
golang.org/x/net v0.52.0 // indirect
8484
golang.org/x/sync v0.20.0 // indirect
8585
golang.org/x/sys v0.43.0 // indirect
8686
golang.org/x/tools v0.43.0 // indirect

internal/common/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package common
22

33
const (
44
TerraformProviderName = "terraform-provider-volcenginecc"
5-
TerraformProviderVersion = "0.0.62"
5+
TerraformProviderVersion = "0.0.63"
66
)

0 commit comments

Comments
 (0)