Skip to content

Commit ce790e6

Browse files
Added new resource "LbEdgeExtension" (#15456)
Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
1 parent 3fa993a commit ce790e6

File tree

3 files changed

+667
-0
lines changed

3 files changed

+667
-0
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'LbEdgeExtension'
16+
description: |
17+
LbEdgeExtension is a resource that lets the extension service influence the selection of backend services and Cloud CDN cache keys by modifying request headers.
18+
references:
19+
guides:
20+
'Configure a edge extension': 'https://cloud.google.com/service-extensions/docs/configure-edge-extensions'
21+
api: 'https://cloud.google.com/service-extensions/docs/reference/rest/v1beta1/projects.locations.lbEdgeExtensions'
22+
docs:
23+
base_url: 'projects/{{project}}/locations/{{location}}/lbEdgeExtensions'
24+
self_link: 'projects/{{project}}/locations/{{location}}/lbEdgeExtensions/{{name}}'
25+
create_url: 'projects/{{project}}/locations/{{location}}/lbEdgeExtensions?lbEdgeExtensionId={{name}}'
26+
update_verb: 'PATCH'
27+
update_mask: true
28+
timeouts:
29+
insert_minutes: 20
30+
update_minutes: 20
31+
delete_minutes: 20
32+
autogen_async: true
33+
async:
34+
actions: ['create', 'delete', 'update']
35+
type: 'OpAsync'
36+
operation:
37+
base_url: '{{op_id}}'
38+
result:
39+
resource_inside_response: false
40+
custom_code:
41+
sweeper:
42+
url_substitutions:
43+
- location: 'global'
44+
examples:
45+
- name: 'network_services_lb_edge_extension_basic'
46+
primary_resource_id: 'default'
47+
test_env_vars:
48+
project: 'PROJECT_NAME'
49+
vars:
50+
forwarding_rule_name: 'elb-forwarding-rule'
51+
target_http_proxy_name: 'elb-target-http-proxy'
52+
url_map_name: 'elb-url-map'
53+
backend_service_name: 'elb-backend-subnet'
54+
lb_edge_extension_name: 'elb-edge-ext'
55+
wasm_plugin_name: 'elb-wasm-plugin-data'
56+
repository_name: 'repository-standard'
57+
exclude_test: true
58+
parameters:
59+
- name: 'location'
60+
type: String
61+
description: |
62+
The location of the edge extension
63+
url_param_only: true
64+
required: true
65+
immutable: true
66+
- name: 'name'
67+
type: String
68+
description: |
69+
Name of the LbEdgeExtension resource in the following format: projects/{project}/locations/{location}/lbEdgeExtensions/{lbEdgeExtensions}
70+
url_param_only: true
71+
required: true
72+
immutable: true
73+
properties:
74+
- name: 'description'
75+
type: String
76+
description: |
77+
A human-readable description of the resource.
78+
- name: 'labels'
79+
type: KeyValueLabels
80+
description: 'Set of labels associated with the LbEdgeExtension resource.'
81+
- name: 'forwardingRules'
82+
type: Array
83+
description: |
84+
A list of references to the forwarding rules to which this service extension is attached.
85+
At least one forwarding rule is required. Only one LbEdgeExtension resource can be associated with a forwarding rule.
86+
required: true
87+
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
88+
item_type:
89+
type: String
90+
- name: 'extensionChains'
91+
type: Array
92+
description: |
93+
A set of ordered extension chains that contain the match conditions and extensions to execute.
94+
Match conditions for each extension chain are evaluated in sequence for a given request.
95+
The first extension chain that has a condition that matches the request is executed.
96+
Any subsequent extension chains do not execute. Limited to 5 extension chains per resource.
97+
required: true
98+
item_type:
99+
type: NestedObject
100+
properties:
101+
- name: 'name'
102+
type: String
103+
description: |
104+
The name for this extension chain. The name is logged as part of the HTTP request logs.
105+
The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens,
106+
and can have a maximum length of 63 characters. Additionally, the first character must be a letter
107+
and the last character must be a letter or a number.
108+
required: true
109+
- name: 'matchCondition'
110+
type: NestedObject
111+
description: |
112+
Conditions under which this chain is invoked for a request.
113+
required: true
114+
properties:
115+
- name: 'celExpression'
116+
type: String
117+
description: |
118+
A Common Expression Language (CEL) expression that is used to match requests for which the extension chain is executed.
119+
required: true
120+
- name: 'extensions'
121+
type: Array
122+
description: |
123+
A set of extensions to execute for the matching request.
124+
At least one extension is required. Up to 3 extensions can be defined for each extension chain for
125+
LbTrafficExtension resource. LbRouteExtension chains are limited to 1 extension per extension chain.
126+
required: true
127+
item_type:
128+
type: NestedObject
129+
properties:
130+
- name: 'name'
131+
type: String
132+
description: |
133+
The name for this extension. The name is logged as part of the HTTP request logs.
134+
The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens,
135+
and can have a maximum length of 63 characters. Additionally, the first character must be a letter
136+
and the last a letter or a number.
137+
required: true
138+
- name: 'service'
139+
type: String
140+
description: |
141+
The reference to the service that runs the extension.
142+
143+
* To configure a callout extension, service must be a fully-qualified reference to a backend service.
144+
* To configure a plugin extension, service must be a reference to a WasmPlugin resource.
145+
required: true
146+
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
147+
- name: 'failOpen'
148+
type: Boolean
149+
description: |
150+
Determines how the proxy behaves if the call to the extension fails or times out.
151+
When set to TRUE, request or response processing continues without error.
152+
Any subsequent extensions in the extension chain are also executed.
153+
When set to FALSE: * If response headers have not been delivered to the downstream client,
154+
a generic 500 error is returned to the client. The error response can be tailored by
155+
configuring a custom error response in the load balancer.
156+
- name: 'supportedEvents'
157+
type: Array
158+
description: |
159+
A set of events during request or response processing for which this extension is called.
160+
This field is required for the LbEdgeExtension resource and only supports the value `REQUEST_HEADERS`.
161+
item_type:
162+
type: String
163+
min_size: 1
164+
- name: 'forwardHeaders'
165+
type: Array
166+
description: |
167+
List of the HTTP headers to forward to the extension (from the client or backend).
168+
If omitted, all headers are sent. Each element is a string indicating the header name.
169+
item_type:
170+
type: String
171+
- name: 'loadBalancingScheme'
172+
type: Enum
173+
description: |
174+
All forwarding rules referenced by this extension must share the same load balancing scheme.
175+
required: true
176+
immutable: true
177+
enum_values:
178+
- 'EXTERNAL_MANAGED'
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# forwarding rule
2+
resource "google_compute_global_forwarding_rule" "default" {
3+
name = "{{index $.Vars "forwarding_rule_name"}}"
4+
target = google_compute_target_http_proxy.default.id
5+
port_range = "80"
6+
load_balancing_scheme = "EXTERNAL_MANAGED"
7+
network_tier = "PREMIUM"
8+
}
9+
10+
resource "google_compute_target_http_proxy" "default" {
11+
name = "{{index $.Vars "target_http_proxy_name"}}"
12+
description = "a description"
13+
url_map = google_compute_url_map.default.id
14+
}
15+
16+
resource "google_compute_url_map" "default" {
17+
name = "{{index $.Vars "url_map_name"}}"
18+
description = "a description"
19+
default_service = google_compute_backend_service.default.id
20+
21+
host_rule {
22+
hosts = ["mysite.com"]
23+
path_matcher = "allpaths"
24+
}
25+
26+
path_matcher {
27+
name = "allpaths"
28+
default_service = google_compute_backend_service.default.id
29+
30+
path_rule {
31+
paths = ["/*"]
32+
service = google_compute_backend_service.default.id
33+
}
34+
}
35+
}
36+
37+
resource "google_compute_backend_service" "default" {
38+
name = "{{index $.Vars "backend_service_name"}}"
39+
port_name = "http"
40+
protocol = "HTTP"
41+
timeout_sec = 10
42+
load_balancing_scheme = "EXTERNAL_MANAGED"
43+
}
44+
45+
resource "google_network_services_lb_edge_extension" "{{$.PrimaryResourceId}}" {
46+
name = "{{index $.Vars "lb_edge_extension_name"}}"
47+
description = "my edge extension"
48+
location = "global"
49+
50+
load_balancing_scheme = "EXTERNAL_MANAGED"
51+
forwarding_rules = [google_compute_global_forwarding_rule.default.self_link]
52+
53+
extension_chains {
54+
name = "chain1"
55+
56+
match_condition {
57+
cel_expression = "request.host == 'example.com'"
58+
}
59+
60+
extensions {
61+
name = "ext11"
62+
service = google_network_services_wasm_plugin.wasm-plugin.id
63+
fail_open = false
64+
supported_events = ["REQUEST_HEADERS"]
65+
forward_headers = ["custom-header"]
66+
}
67+
}
68+
69+
labels = {
70+
foo = "bar"
71+
}
72+
}
73+
74+
resource "google_network_services_wasm_plugin" "wasm-plugin" {
75+
name = "{{index $.Vars "wasm_plugin_name"}}"
76+
description = "my wasm plugin"
77+
78+
main_version_id = "v1"
79+
80+
labels = {
81+
test_label = "test_value"
82+
}
83+
log_config {
84+
enable = true
85+
sample_rate = 1
86+
min_log_level = "WARN"
87+
}
88+
89+
versions {
90+
version_name = "v1"
91+
description = "v1 version of my wasm plugin"
92+
image_uri = "projects/{{index $.TestEnvVars "project"}}/locations/us-central1/repositories/{{index $.Vars "repository_name"}}/genericArtifacts/my-wasm-plugin:v1"
93+
94+
labels = {
95+
test_label = "test_value"
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)