@@ -101,6 +101,77 @@ resource "google_compute_http_health_check" "default" {
101
101
` , context )
102
102
}
103
103
104
+ func TestAccComputeGlobalForwardingRule_globalForwardingRuleExternalManagedExample (t * testing.T ) {
105
+ t .Parallel ()
106
+
107
+ context := map [string ]interface {}{
108
+ "random_suffix" : randString (t , 10 ),
109
+ }
110
+
111
+ vcrTest (t , resource.TestCase {
112
+ PreCheck : func () { testAccPreCheck (t ) },
113
+ Providers : testAccProviders ,
114
+ CheckDestroy : testAccCheckComputeGlobalForwardingRuleDestroyProducer (t ),
115
+ Steps : []resource.TestStep {
116
+ {
117
+ Config : testAccComputeGlobalForwardingRule_globalForwardingRuleExternalManagedExample (context ),
118
+ },
119
+ {
120
+ ResourceName : "google_compute_global_forwarding_rule.default" ,
121
+ ImportState : true ,
122
+ ImportStateVerify : true ,
123
+ ImportStateVerifyIgnore : []string {"port_range" , "target" },
124
+ },
125
+ },
126
+ })
127
+ }
128
+
129
+ func testAccComputeGlobalForwardingRule_globalForwardingRuleExternalManagedExample (context map [string ]interface {}) string {
130
+ return Nprintf (`
131
+ resource "google_compute_global_forwarding_rule" "default" {
132
+ name = "tf-test-global-rule%{random_suffix}"
133
+ target = google_compute_target_http_proxy.default.id
134
+ port_range = "80"
135
+ load_balancing_scheme = "EXTERNAL_MANAGED"
136
+ }
137
+
138
+ resource "google_compute_target_http_proxy" "default" {
139
+ name = "tf-test-target-proxy%{random_suffix}"
140
+ description = "a description"
141
+ url_map = google_compute_url_map.default.id
142
+ }
143
+
144
+ resource "google_compute_url_map" "default" {
145
+ name = "url-map-tf-test-target-proxy%{random_suffix}"
146
+ description = "a description"
147
+ default_service = google_compute_backend_service.default.id
148
+
149
+ host_rule {
150
+ hosts = ["mysite.com"]
151
+ path_matcher = "allpaths"
152
+ }
153
+
154
+ path_matcher {
155
+ name = "allpaths"
156
+ default_service = google_compute_backend_service.default.id
157
+
158
+ path_rule {
159
+ paths = ["/*"]
160
+ service = google_compute_backend_service.default.id
161
+ }
162
+ }
163
+ }
164
+
165
+ resource "google_compute_backend_service" "default" {
166
+ name = "backend%{random_suffix}"
167
+ port_name = "http"
168
+ protocol = "HTTP"
169
+ timeout_sec = 10
170
+ load_balancing_scheme = "EXTERNAL_MANAGED"
171
+ }
172
+ ` , context )
173
+ }
174
+
104
175
func testAccCheckComputeGlobalForwardingRuleDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
105
176
return func (s * terraform.State ) error {
106
177
for name , rs := range s .RootModule ().Resources {
0 commit comments