Skip to content

Commit 2160ab7

Browse files
authored
azurerm_application_gateway - support for backend, listener and routing_rule block (hashicorp#30376)
[ENHANCEMENT] * `azurerm_application_gateway` - add support for the `backend`, `listener`, and `routing_rule` arguments
1 parent 978edb0 commit 2160ab7

20 files changed

+3773
-259
lines changed

internal/services/network/application_gateway_data_source.go

Lines changed: 249 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,67 @@ func dataSourceApplicationGateway() *pluginsdk.Resource {
186186
},
187187
},
188188

189+
"backend": {
190+
Type: pluginsdk.TypeList,
191+
Computed: true,
192+
Elem: &pluginsdk.Resource{
193+
Schema: map[string]*pluginsdk.Schema{
194+
"client_ip_preservation_enabled": {
195+
Type: pluginsdk.TypeBool,
196+
Computed: true,
197+
},
198+
199+
"host_name": {
200+
Type: pluginsdk.TypeString,
201+
Computed: true,
202+
},
203+
204+
"id": {
205+
Type: pluginsdk.TypeString,
206+
Computed: true,
207+
},
208+
209+
"name": {
210+
Type: pluginsdk.TypeString,
211+
Computed: true,
212+
},
213+
214+
"port": {
215+
Type: pluginsdk.TypeInt,
216+
Computed: true,
217+
},
218+
219+
"probe_id": {
220+
Type: pluginsdk.TypeString,
221+
Computed: true,
222+
},
223+
224+
"probe_name": {
225+
Type: pluginsdk.TypeString,
226+
Computed: true,
227+
},
228+
229+
"protocol": {
230+
Type: pluginsdk.TypeString,
231+
Computed: true,
232+
},
233+
234+
"timeout_in_seconds": {
235+
Type: pluginsdk.TypeInt,
236+
Computed: true,
237+
},
238+
239+
"trusted_root_certificate_names": {
240+
Type: pluginsdk.TypeList,
241+
Computed: true,
242+
Elem: &pluginsdk.Schema{
243+
Type: pluginsdk.TypeString,
244+
},
245+
},
246+
},
247+
},
248+
},
249+
189250
"frontend_ip_configuration": {
190251
Type: pluginsdk.TypeList,
191252
Computed: true,
@@ -406,6 +467,77 @@ func dataSourceApplicationGateway() *pluginsdk.Resource {
406467
},
407468
},
408469

470+
"listener": {
471+
Type: pluginsdk.TypeList,
472+
Computed: true,
473+
Elem: &pluginsdk.Resource{
474+
Schema: map[string]*pluginsdk.Schema{
475+
"frontend_ip_configuration_id": {
476+
Type: pluginsdk.TypeString,
477+
Computed: true,
478+
},
479+
480+
"frontend_ip_configuration_name": {
481+
Type: pluginsdk.TypeString,
482+
Computed: true,
483+
},
484+
485+
"frontend_port_id": {
486+
Type: pluginsdk.TypeString,
487+
Computed: true,
488+
},
489+
490+
"frontend_port_name": {
491+
Type: pluginsdk.TypeString,
492+
Computed: true,
493+
},
494+
495+
"host_names": {
496+
Type: pluginsdk.TypeList,
497+
Computed: true,
498+
Elem: &pluginsdk.Schema{
499+
Type: pluginsdk.TypeString,
500+
},
501+
},
502+
503+
"id": {
504+
Type: pluginsdk.TypeString,
505+
Computed: true,
506+
},
507+
508+
"name": {
509+
Type: pluginsdk.TypeString,
510+
Computed: true,
511+
},
512+
513+
"protocol": {
514+
Type: pluginsdk.TypeString,
515+
Computed: true,
516+
},
517+
518+
"ssl_certificate_id": {
519+
Type: pluginsdk.TypeString,
520+
Computed: true,
521+
},
522+
523+
"ssl_certificate_name": {
524+
Type: pluginsdk.TypeString,
525+
Computed: true,
526+
},
527+
528+
"ssl_profile_id": {
529+
Type: pluginsdk.TypeString,
530+
Computed: true,
531+
},
532+
533+
"ssl_profile_name": {
534+
Type: pluginsdk.TypeString,
535+
Computed: true,
536+
},
537+
},
538+
},
539+
},
540+
409541
"fips_enabled": {
410542
Type: pluginsdk.TypeBool,
411543
Computed: true,
@@ -565,6 +697,59 @@ func dataSourceApplicationGateway() *pluginsdk.Resource {
565697
},
566698
},
567699

700+
"routing_rule": {
701+
Type: pluginsdk.TypeList,
702+
Computed: true,
703+
Elem: &pluginsdk.Resource{
704+
Schema: map[string]*pluginsdk.Schema{
705+
"backend_address_pool_id": {
706+
Type: pluginsdk.TypeString,
707+
Computed: true,
708+
},
709+
710+
"backend_address_pool_name": {
711+
Type: pluginsdk.TypeString,
712+
Computed: true,
713+
},
714+
715+
"backend_id": {
716+
Type: pluginsdk.TypeString,
717+
Computed: true,
718+
},
719+
720+
"backend_name": {
721+
Type: pluginsdk.TypeString,
722+
Computed: true,
723+
},
724+
725+
"id": {
726+
Type: pluginsdk.TypeString,
727+
Computed: true,
728+
},
729+
730+
"listener_id": {
731+
Type: pluginsdk.TypeString,
732+
Computed: true,
733+
},
734+
735+
"listener_name": {
736+
Type: pluginsdk.TypeString,
737+
Computed: true,
738+
},
739+
740+
"name": {
741+
Type: pluginsdk.TypeString,
742+
Computed: true,
743+
},
744+
745+
"priority": {
746+
Type: pluginsdk.TypeInt,
747+
Computed: true,
748+
},
749+
},
750+
},
751+
},
752+
568753
"redirect_configuration": {
569754
Type: pluginsdk.TypeList,
570755
Computed: true,
@@ -747,43 +932,54 @@ func dataSourceApplicationGateway() *pluginsdk.Resource {
747932
Computed: true,
748933
Elem: &pluginsdk.Resource{
749934
Schema: map[string]*pluginsdk.Schema{
750-
"name": {
935+
"host": {
751936
Type: pluginsdk.TypeString,
752937
Computed: true,
753938
},
754939

755-
"protocol": {
940+
"id": {
756941
Type: pluginsdk.TypeString,
757942
Computed: true,
758943
},
759944

760-
"path": {
761-
Type: pluginsdk.TypeString,
945+
"interval": {
946+
Type: pluginsdk.TypeInt,
762947
Computed: true,
763948
},
764949

765-
"host": {
766-
Type: pluginsdk.TypeString,
950+
"match": {
951+
Type: pluginsdk.TypeList,
767952
Computed: true,
768-
},
953+
Elem: &pluginsdk.Resource{
954+
Schema: map[string]*pluginsdk.Schema{
955+
"body": {
956+
Type: pluginsdk.TypeString,
957+
Computed: true,
958+
},
769959

770-
"interval": {
771-
Type: pluginsdk.TypeInt,
772-
Computed: true,
960+
"status_code": {
961+
Type: pluginsdk.TypeList,
962+
Computed: true,
963+
Elem: &pluginsdk.Schema{
964+
Type: pluginsdk.TypeString,
965+
},
966+
},
967+
},
968+
},
773969
},
774970

775-
"timeout": {
971+
"minimum_servers": {
776972
Type: pluginsdk.TypeInt,
777973
Computed: true,
778974
},
779975

780-
"unhealthy_threshold": {
781-
Type: pluginsdk.TypeInt,
976+
"name": {
977+
Type: pluginsdk.TypeString,
782978
Computed: true,
783979
},
784980

785-
"port": {
786-
Type: pluginsdk.TypeInt,
981+
"path": {
982+
Type: pluginsdk.TypeString,
787983
Computed: true,
788984
},
789985

@@ -792,34 +988,28 @@ func dataSourceApplicationGateway() *pluginsdk.Resource {
792988
Computed: true,
793989
},
794990

795-
"minimum_servers": {
991+
"port": {
796992
Type: pluginsdk.TypeInt,
797993
Computed: true,
798994
},
799995

800-
"match": {
801-
Type: pluginsdk.TypeList,
996+
"protocol": {
997+
Type: pluginsdk.TypeString,
802998
Computed: true,
803-
Elem: &pluginsdk.Resource{
804-
Schema: map[string]*pluginsdk.Schema{
805-
"body": {
806-
Type: pluginsdk.TypeString,
807-
Computed: true,
808-
},
999+
},
8091000

810-
"status_code": {
811-
Type: pluginsdk.TypeList,
812-
Computed: true,
813-
Elem: &pluginsdk.Schema{
814-
Type: pluginsdk.TypeString,
815-
},
816-
},
817-
},
818-
},
1001+
"proxy_protocol_header_enabled": {
1002+
Type: pluginsdk.TypeBool,
1003+
Computed: true,
8191004
},
8201005

821-
"id": {
822-
Type: pluginsdk.TypeString,
1006+
"timeout": {
1007+
Type: pluginsdk.TypeInt,
1008+
Computed: true,
1009+
},
1010+
1011+
"unhealthy_threshold": {
1012+
Type: pluginsdk.TypeInt,
8231013
Computed: true,
8241014
},
8251015
},
@@ -1377,6 +1567,14 @@ func dataSourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{
13771567
return fmt.Errorf("setting `backend_http_settings`: %+v", setErr)
13781568
}
13791569

1570+
backendSettings, err := flattenApplicationGatewayBackendSettings(props.BackendSettingsCollection)
1571+
if err != nil {
1572+
return fmt.Errorf("flattening `backend`: %+v", err)
1573+
}
1574+
if setErr := d.Set("backend", backendSettings); setErr != nil {
1575+
return fmt.Errorf("setting `backend`: %+v", setErr)
1576+
}
1577+
13801578
if setErr := d.Set("ssl_policy", flattenApplicationGatewaySslPolicy(props.SslPolicy)); setErr != nil {
13811579
return fmt.Errorf("setting `ssl_policy`: %+v", setErr)
13821580
}
@@ -1393,6 +1591,14 @@ func dataSourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{
13931591
return fmt.Errorf("setting `http_listener`: %+v", setErr)
13941592
}
13951593

1594+
listeners, err := flattenApplicationGatewayListeners(props.Listeners)
1595+
if err != nil {
1596+
return fmt.Errorf("flattening `listener`: %+v", err)
1597+
}
1598+
if setErr := d.Set("listener", listeners); setErr != nil {
1599+
return fmt.Errorf("setting `listener`: %+v", setErr)
1600+
}
1601+
13961602
if setErr := d.Set("frontend_port", flattenApplicationGatewayFrontendPorts(props.FrontendPorts)); setErr != nil {
13971603
return fmt.Errorf("setting `frontend_port`: %+v", setErr)
13981604
}
@@ -1433,6 +1639,14 @@ func dataSourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{
14331639
return fmt.Errorf("setting `request_routing_rule`: %+v", setErr)
14341640
}
14351641

1642+
routingRules, err := flattenApplicationGatewayRoutingRules(props.RoutingRules)
1643+
if err != nil {
1644+
return fmt.Errorf("flattening `routing_rule`: %+v", err)
1645+
}
1646+
if setErr := d.Set("routing_rule", routingRules); setErr != nil {
1647+
return fmt.Errorf("setting `routing_rule`: %+v", setErr)
1648+
}
1649+
14361650
redirectConfigurations, err := flattenApplicationGatewayRedirectConfigurations(props.RedirectConfigurations)
14371651
if err != nil {
14381652
return fmt.Errorf("flattening `redirect configuration`: %+v", err)

0 commit comments

Comments
 (0)