Skip to content

Commit fec4af7

Browse files
authored
update docs (#37)
updates provider reference documentation. Ref: https://linear.app/pomerium/issue/ENG-1755/docsterraform-add-provider-documentation
1 parent 925616f commit fec4af7

File tree

5 files changed

+181
-46
lines changed

5 files changed

+181
-46
lines changed

README.md

+67-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,67 @@
1-
# enterprise-terraform-provider
1+
# Pomerium Terraform Provider
2+
3+
[![Terraform](https://img.shields.io/badge/Terraform-v1.0+-blue.svg)](https://www.terraform.io)
4+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5+
6+
The Pomerium Terraform Provider enables management of Pomerium Enterprise resources through Terraform.
7+
8+
## Quick Start
9+
10+
Configure the provider in your Terraform configuration:
11+
12+
```terraform
13+
terraform {
14+
required_providers {
15+
pomerium = {
16+
source = "pomerium/pomerium"
17+
version = "~> 0.0.7"
18+
}
19+
}
20+
}
21+
22+
provider "pomerium" {
23+
api_url = "https://console-api.your-domain.com"
24+
# Choose one of the authentication methods below:
25+
26+
# Option 1: Service Account Token
27+
service_account_token = var.pomerium_service_account_token
28+
29+
# Option 2: Bootstrap Service Account
30+
# shared_secret_b64 = var.shared_secret_b64
31+
}
32+
```
33+
34+
## Authentication
35+
36+
Two authentication methods are supported:
37+
38+
1. **Service Account Token** (Recommended)
39+
- Uses a [Pomerium Enterprise Service Account](https://www.pomerium.com/docs/capabilities/service-accounts)
40+
- Provides namespace-level access control
41+
- Configure using `service_account_token`
42+
43+
2. **Bootstrap Service Account**
44+
- Requires `BOOTSTRAP_SERVICE_ACCOUNT=true` in Enterprise Console
45+
- Configure using `shared_secret_b64`
46+
47+
## Documentation
48+
49+
- [Provider Documentation](https://registry.terraform.io/providers/pomerium/pomerium/latest/docs)
50+
- [Example Configurations](https://github.com/pomerium/enterprise-terraform-provider/tree/main/examples)
51+
- [Kubernetes Deployment Guide](https://github.com/pomerium/install/tree/main/enterprise/terraform/kubernetes)
52+
53+
## Resources and Data Sources
54+
55+
Common resources:
56+
- `pomerium_namespace`
57+
- `pomerium_policy`
58+
- `pomerium_route`
59+
- `pomerium_settings`
60+
- `pomerium_service_account`
61+
62+
Data sources:
63+
- `pomerium_namespaces`
64+
- `pomerium_namespace`
65+
- `pomerium_route`
66+
67+
For detailed examples, see our [examples directory](examples/) or the [provider documentation](https://registry.terraform.io/providers/pomerium/pomerium/latest/docs).

internal/provider/help/provider.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Pomerium Provider
2+
3+
The Pomerium provider enables management of Pomerium Enterprise resources through Terraform. It provides resources and data sources for managing policies, routes, namespaces, and other Pomerium Enterprise features.
4+
5+
## Example Usage
6+
7+
```terraform
8+
terraform {
9+
required_providers {
10+
pomerium = {
11+
source = "pomerium/pomerium"
12+
version = "~> 0.0.7"
13+
}
14+
}
15+
}
16+
17+
provider "pomerium" {
18+
api_url = "https://console-api.your-domain.com"
19+
# Choose one authentication method:
20+
service_account_token = var.pomerium_service_account_token
21+
# shared_secret_b64 = var.shared_secret_b64
22+
}
23+
```
24+
25+
## Authentication Methods
26+
27+
The provider supports two authentication methods:
28+
29+
### Service Account Token (Recommended)
30+
31+
Uses a Pomerium Enterprise Service Account token for authentication. This method provides fine-grained access control at the namespace level.
32+
33+
```terraform
34+
provider "pomerium" {
35+
api_url = "https://console-api.your-domain.com"
36+
service_account_token = var.pomerium_service_account_token
37+
}
38+
```
39+
40+
### Bootstrap Service Account
41+
42+
Uses the Enterprise Console's shared secret for authentication. Requires `BOOTSTRAP_SERVICE_ACCOUNT=true` in the Enterprise Console configuration.
43+
44+
```terraform
45+
provider "pomerium" {
46+
api_url = "https://console-api.your-domain.com"
47+
shared_secret_b64 = var.shared_secret_b64
48+
}
49+
```
50+
51+
## Schema
52+
53+
### Required
54+
55+
- `api_url` (String) - The URL of your Pomerium Enterprise Console API endpoint.
56+
57+
### Optional
58+
59+
- `service_account_token` (String, Sensitive) - A Pomerium Enterprise Service Account token. Mutually exclusive with `shared_secret_b64`.
60+
- `shared_secret_b64` (String, Sensitive) - The base64-encoded shared secret from your Pomerium Enterprise Console. Mutually exclusive with `service_account_token`.
61+
- `tls_insecure_skip_verify` (Boolean) - Skip TLS certificate verification. Should only be used in testing environments.
62+
63+
~> **Note:** You must specify either `service_account_token` or `shared_secret_b64`, but not both.
64+

internal/provider/provider.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package provider
33
import (
44
"context"
55
"crypto/tls"
6+
_ "embed" // embed is used to embed the provider description
67
"net"
78
"net/url"
89

@@ -21,6 +22,9 @@ import (
2122
var (
2223
_ provider.Provider = &PomeriumProvider{}
2324
_ provider.ProviderWithFunctions = &PomeriumProvider{}
25+
26+
//go:embed help/provider.md
27+
providerDescription string
2428
)
2529

2630
// PomeriumProvider defines the provider implementation.
@@ -46,6 +50,7 @@ func (p *PomeriumProvider) Metadata(_ context.Context, _ provider.MetadataReques
4650

4751
func (p *PomeriumProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
4852
resp.Schema = schema.Schema{
53+
MarkdownDescription: providerDescription,
4954
Attributes: map[string]schema.Attribute{
5055
"api_url": schema.StringAttribute{
5156
MarkdownDescription: "Pomerium Enterprise API URL",

internal/provider/route.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ func (r *RouteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
5757
Required: true,
5858
},
5959
"from": schema.StringAttribute{
60-
Description: "From URL.",
60+
Description: "The external URL for a proxied request. Must contain a scheme and Hostname, must not contain a path.",
6161
Required: true,
6262
},
6363
"to": schema.SetAttribute{
6464
ElementType: types.StringType,
65-
Description: "To URLs.",
65+
Description: "The destination(s) of a proxied request. Must contain a scheme and Hostname, with an optional weight.",
6666
Required: true,
6767
},
6868
"namespace_id": schema.StringAttribute{
@@ -80,75 +80,75 @@ func (r *RouteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
8080
Computed: true,
8181
},
8282
"prefix": schema.StringAttribute{
83-
Description: "Prefix.",
83+
Description: "Matches incoming requests with a path that begins with the specified prefix.",
8484
Optional: true,
8585
},
8686
"path": schema.StringAttribute{
87-
Description: "Path.",
87+
Description: "Matches incoming requests with a path that is an exact match for the specified path.",
8888
Optional: true,
8989
},
9090
"regex": schema.StringAttribute{
91-
Description: "Regex.",
91+
Description: "Matches incoming requests with a path that matches the specified regular expression.",
9292
Optional: true,
9393
},
9494
"prefix_rewrite": schema.StringAttribute{
95-
Description: "Prefix rewrite.",
95+
Description: "While forwarding a request, Prefix Rewrite swaps the matched prefix (or path) with the specified value.",
9696
Optional: true,
9797
},
9898
"regex_rewrite_pattern": schema.StringAttribute{
99-
Description: "Regex rewrite pattern.",
99+
Description: "Rewrites the URL path according to the regex rewrite pattern.",
100100
Optional: true,
101101
},
102102
"regex_rewrite_substitution": schema.StringAttribute{
103-
Description: "Regex rewrite substitution.",
103+
Description: "Rewrites the URL path according to the regex rewrite substitution.",
104104
Optional: true,
105105
},
106106
"host_rewrite": schema.StringAttribute{
107-
Description: "Host rewrite.",
107+
Description: "Rewrites the Host header to a new literal value.",
108108
Optional: true,
109109
},
110110
"host_rewrite_header": schema.StringAttribute{
111-
Description: "Host rewrite header.",
111+
Description: "Rewrites the Host header to match an incoming header value.",
112112
Optional: true,
113113
},
114114
"host_path_regex_rewrite_pattern": schema.StringAttribute{
115-
Description: "Host path regex rewrite pattern.",
115+
Description: "Rewrites the Host header according to a regular expression matching the path.",
116116
Optional: true,
117117
},
118118
"host_path_regex_rewrite_substitution": schema.StringAttribute{
119-
Description: "Host path regex rewrite substitution.",
119+
Description: "Rewrites the Host header according to a regular expression matching the substitution.",
120120
Optional: true,
121121
},
122122
"regex_priority_order": schema.Int64Attribute{
123123
Description: "Regex priority order.",
124124
Optional: true,
125125
},
126126
"timeout": schema.StringAttribute{
127-
Description: "Timeout.",
127+
Description: "Sets the per-route timeout value. Cannot exceed global timeout values. Defaults to 30 seconds.",
128128
Optional: true,
129129
CustomType: timetypes.GoDurationType{},
130130
Computed: true,
131131
},
132132
"idle_timeout": schema.StringAttribute{
133-
Description: "Idle timeout.",
133+
Description: "Sets the time to terminate the upstream connection if there are no active streams. Defaults to 5 minutes.",
134134
Optional: true,
135135
CustomType: timetypes.GoDurationType{},
136136
Computed: true,
137137
},
138138
"allow_websockets": schema.BoolAttribute{
139-
Description: "Allow websockets.",
139+
Description: "If applied, this setting enables Pomerium to proxy websocket connections.",
140140
Optional: true,
141141
},
142142
"allow_spdy": schema.BoolAttribute{
143-
Description: "Allow SPDY.",
143+
Description: "If applied, this setting enables Pomerium to proxy SPDY protocol upgrades.",
144144
Optional: true,
145145
},
146146
"tls_skip_verify": schema.BoolAttribute{
147-
Description: "TLS skip verify.",
147+
Description: "If applied, Pomerium accepts any certificate presented by the upstream server and any Hostname in that certificate. Use for testing only.",
148148
Optional: true,
149149
},
150150
"tls_upstream_server_name": schema.StringAttribute{
151-
Description: "TLS upstream server name.",
151+
Description: "This server name overrides the Hostname in the 'To:' field, and will be used to verify the certificate name.",
152152
Optional: true,
153153
},
154154
"tls_downstream_server_name": schema.StringAttribute{
@@ -161,25 +161,25 @@ func (r *RouteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
161161
},
162162
"set_request_headers": schema.MapAttribute{
163163
ElementType: types.StringType,
164-
Description: "Set request headers.",
164+
Description: "Sets static and dynamic values for given request headers. Available substitutions: ${pomerium.id_token}, ${pomerium.access_token}, ${pomerium.client_cert_fingerprint}.",
165165
Optional: true,
166166
},
167167
"remove_request_headers": schema.SetAttribute{
168168
ElementType: types.StringType,
169-
Description: "Remove request headers.",
169+
Description: "Removes given request headers so they do not reach the upstream server.",
170170
Optional: true,
171171
},
172172
"set_response_headers": schema.MapAttribute{
173173
ElementType: types.StringType,
174-
Description: "Set response headers.",
174+
Description: "Sets static HTTP Response Header values for a route. These headers take precedence over globally set response headers.",
175175
Optional: true,
176176
},
177177
"preserve_host_header": schema.BoolAttribute{
178-
Description: "Preserve host header.",
178+
Description: "Passes the host header from the incoming request to the proxied host, instead of the destination hostname.",
179179
Optional: true,
180180
},
181181
"pass_identity_headers": schema.BoolAttribute{
182-
Description: "Pass identity headers.",
182+
Description: "If applied, passes X-Pomerium-Jwt-Assertion header and JWT Claims Headers to the upstream application.",
183183
Optional: true,
184184
},
185185
"kubernetes_service_account_token": schema.StringAttribute{
@@ -195,7 +195,7 @@ func (r *RouteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
195195
Optional: true,
196196
},
197197
"show_error_details": schema.BoolAttribute{
198-
Description: "Show error details.",
198+
Description: "If applied, shows error details, including policy explanation and remediation for 403 Forbidden responses.",
199199
Optional: true,
200200
Computed: true,
201201
},
@@ -208,7 +208,7 @@ func (r *RouteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
208208
},
209209
},
210210
"rewrite_response_headers": schema.SetNestedAttribute{
211-
Description: "Response header rewrite rules.",
211+
Description: "Modifies response headers before they are returned to the client. 'Header' matches the HTTP header name; 'prefix' will be replaced with 'value'.",
212212
Optional: true,
213213
NestedObject: schema.NestedAttributeObject{
214214
Attributes: map[string]schema.Attribute{

0 commit comments

Comments
 (0)