Skip to content

Commit 925616f

Browse files
authored
add more route options (#36)
1 parent 5d3bbae commit 925616f

File tree

5 files changed

+515
-48
lines changed

5 files changed

+515
-48
lines changed

example/main.tf

+38-3
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,51 @@ resource "pomerium_route" "kubernetes_route" {
203203
tls_upstream_allow_renegotiation = true
204204
}
205205

206+
resource "pomerium_route" "advanced_route" {
207+
name = "advanced-route"
208+
from = "https://advanced.corp.example.com"
209+
to = ["https://internal-service.example.com"]
210+
namespace_id = pomerium_namespace.test_namespace.id
211+
212+
# Response header manipulation
213+
rewrite_response_headers = [
214+
{
215+
header = "Location"
216+
prefix = "http://internal"
217+
value = "https://external"
218+
},
219+
{
220+
header = "Content-Security-Policy"
221+
value = "default-src 'self'"
222+
}
223+
]
224+
set_response_headers = {
225+
"Strict-Transport-Security" = "max-age=31536000"
226+
"X-Frame-Options" = "DENY"
227+
}
228+
229+
tls_custom_ca_key_pair_id = pomerium_key_pair.test_key_pair.id
230+
tls_skip_verify = false
231+
232+
enable_google_cloud_serverless_authentication = true
233+
kubernetes_service_account_token_file = "/path/to/token"
234+
235+
description = "Advanced route with security headers"
236+
logo_url = "https://example.com/logo.png"
237+
238+
show_error_details = true
239+
}
240+
206241
# Data source examples
207242
data "pomerium_namespaces" "all_namespaces" {}
208243

209244
data "pomerium_namespace" "existing_namespace" {
210245
id = pomerium_namespace.test_namespace.id
211246
}
212247

213-
# data "pomerium_route" "existing_route" {
214-
# id = pomerium_route.test_route.id
215-
# }
248+
data "pomerium_route" "existing_route" {
249+
id = pomerium_route.test_route.id
250+
}
216251

217252
# Output examples
218253
output "namespace_name" {

internal/provider/route.go

+52
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
8+
"github.com/hashicorp/terraform-plugin-framework/attr"
89
"github.com/hashicorp/terraform-plugin-framework/path"
910
"github.com/hashicorp/terraform-plugin-framework/resource"
1011
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
@@ -199,6 +200,57 @@ func (r *RouteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
199200
Computed: true,
200201
},
201202
"jwt_groups_filter": JWTGroupsFilterSchema,
203+
"jwt_issuer_format": schema.ObjectAttribute{
204+
Description: "JWT issuer format configuration.",
205+
Optional: true,
206+
AttributeTypes: map[string]attr.Type{
207+
"format": types.StringType,
208+
},
209+
},
210+
"rewrite_response_headers": schema.SetNestedAttribute{
211+
Description: "Response header rewrite rules.",
212+
Optional: true,
213+
NestedObject: schema.NestedAttributeObject{
214+
Attributes: map[string]schema.Attribute{
215+
"header": schema.StringAttribute{
216+
Required: true,
217+
Description: "Header name to rewrite",
218+
},
219+
"prefix": schema.StringAttribute{
220+
Optional: true,
221+
Description: "Prefix matcher for the header",
222+
},
223+
"value": schema.StringAttribute{
224+
Required: true,
225+
Description: "New value for the header",
226+
},
227+
},
228+
},
229+
},
230+
"tls_custom_ca_key_pair_id": schema.StringAttribute{
231+
Description: "Custom CA key pair ID for TLS verification.",
232+
Optional: true,
233+
},
234+
"tls_client_key_pair_id": schema.StringAttribute{
235+
Description: "Client key pair ID for TLS client authentication.",
236+
Optional: true,
237+
},
238+
"description": schema.StringAttribute{
239+
Description: "Description of the route.",
240+
Optional: true,
241+
},
242+
"kubernetes_service_account_token_file": schema.StringAttribute{
243+
Description: "Path to the Kubernetes service account token file.",
244+
Optional: true,
245+
},
246+
"logo_url": schema.StringAttribute{
247+
Description: "URL to the logo image.",
248+
Optional: true,
249+
},
250+
"enable_google_cloud_serverless_authentication": schema.BoolAttribute{
251+
Description: "Enable Google Cloud serverless authentication.",
252+
Optional: true,
253+
},
202254
},
203255
}
204256
}

internal/provider/route_data_source.go

+56-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
8+
"github.com/hashicorp/terraform-plugin-framework/attr"
89
"github.com/hashicorp/terraform-plugin-framework/datasource"
910
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
1011
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -30,7 +31,7 @@ func getRouteDataSourceAttributes(idRequired bool) map[string]schema.Attribute {
3031
Computed: true,
3132
Description: "From URL.",
3233
},
33-
"to": schema.ListAttribute{
34+
"to": schema.SetAttribute{
3435
Computed: true,
3536
ElementType: types.StringType,
3637
Description: "To URLs.",
@@ -39,7 +40,7 @@ func getRouteDataSourceAttributes(idRequired bool) map[string]schema.Attribute {
3940
Computed: true,
4041
Description: "ID of the namespace the route belongs to.",
4142
},
42-
"policies": schema.ListAttribute{
43+
"policies": schema.SetAttribute{
4344
Computed: true,
4445
ElementType: types.StringType,
4546
Description: "List of policy IDs associated with the route.",
@@ -131,7 +132,7 @@ func getRouteDataSourceAttributes(idRequired bool) map[string]schema.Attribute {
131132
ElementType: types.StringType,
132133
Description: "Set request headers.",
133134
},
134-
"remove_request_headers": schema.ListAttribute{
135+
"remove_request_headers": schema.SetAttribute{
135136
Computed: true,
136137
ElementType: types.StringType,
137138
Description: "Remove request headers.",
@@ -165,6 +166,58 @@ func getRouteDataSourceAttributes(idRequired bool) map[string]schema.Attribute {
165166
Computed: true,
166167
Description: "Show error details.",
167168
},
169+
"jwt_groups_filter": JWTGroupsFilterSchema,
170+
"jwt_issuer_format": schema.ObjectAttribute{
171+
Description: "JWT issuer format configuration.",
172+
Computed: true,
173+
AttributeTypes: map[string]attr.Type{
174+
"format": types.StringType,
175+
},
176+
},
177+
"rewrite_response_headers": schema.SetNestedAttribute{
178+
Description: "Response header rewrite rules.",
179+
Computed: true,
180+
NestedObject: schema.NestedAttributeObject{
181+
Attributes: map[string]schema.Attribute{
182+
"header": schema.StringAttribute{
183+
Required: true,
184+
Description: "Header name to rewrite",
185+
},
186+
"prefix": schema.StringAttribute{
187+
Optional: true,
188+
Description: "Prefix matcher for the header",
189+
},
190+
"value": schema.StringAttribute{
191+
Required: true,
192+
Description: "New value for the header",
193+
},
194+
},
195+
},
196+
},
197+
"tls_custom_ca_key_pair_id": schema.StringAttribute{
198+
Description: "Custom CA key pair ID for TLS verification.",
199+
Computed: true,
200+
},
201+
"tls_client_key_pair_id": schema.StringAttribute{
202+
Description: "Client key pair ID for TLS client authentication.",
203+
Computed: true,
204+
},
205+
"description": schema.StringAttribute{
206+
Description: "Description of the route.",
207+
Computed: true,
208+
},
209+
"kubernetes_service_account_token_file": schema.StringAttribute{
210+
Description: "Path to the Kubernetes service account token file.",
211+
Computed: true,
212+
},
213+
"logo_url": schema.StringAttribute{
214+
Description: "URL to the logo image.",
215+
Computed: true,
216+
},
217+
"enable_google_cloud_serverless_authentication": schema.BoolAttribute{
218+
Description: "Enable Google Cloud serverless authentication.",
219+
Computed: true,
220+
},
168221
}
169222
}
170223

0 commit comments

Comments
 (0)