@@ -1151,9 +1151,16 @@ func resourceApplicationGateway() *pluginsdk.Resource {
11511151 Optional : true ,
11521152 Elem : & pluginsdk.Resource {
11531153 Schema : map [string ]* pluginsdk.Schema {
1154+ "interval" : {
1155+ Type : pluginsdk .TypeInt ,
1156+ Required : true ,
1157+ ValidateFunc : validation .IntBetween (1 , 86400 ),
1158+ },
1159+
11541160 "name" : {
1155- Type : pluginsdk .TypeString ,
1156- Required : true ,
1161+ Type : pluginsdk .TypeString ,
1162+ Required : true ,
1163+ ValidateFunc : networkValidate .ApplicationGatewayName ,
11571164 },
11581165
11591166 "protocol" : {
@@ -1167,47 +1174,22 @@ func resourceApplicationGateway() *pluginsdk.Resource {
11671174 }, false ),
11681175 },
11691176
1170- "path" : {
1171- Type : pluginsdk .TypeString ,
1172- Optional : true ,
1173- },
1174-
1175- "host" : {
1176- Type : pluginsdk .TypeString ,
1177- Optional : true ,
1178- },
1179-
1180- "interval" : {
1181- Type : pluginsdk .TypeInt ,
1182- Required : true ,
1183- },
1184-
11851177 "timeout" : {
1186- Type : pluginsdk .TypeInt ,
1187- Required : true ,
1178+ Type : pluginsdk .TypeInt ,
1179+ Required : true ,
1180+ ValidateFunc : validation .IntBetween (1 , 86400 ),
11881181 },
11891182
11901183 "unhealthy_threshold" : {
1191- Type : pluginsdk .TypeInt ,
1192- Required : true ,
1193- },
1194-
1195- "port" : {
11961184 Type : pluginsdk .TypeInt ,
1197- Optional : true ,
1198- ValidateFunc : validate .PortNumber ,
1199- },
1200-
1201- "pick_host_name_from_backend_http_settings" : {
1202- Type : pluginsdk .TypeBool ,
1203- Optional : true ,
1204- Default : false ,
1185+ Required : true ,
1186+ ValidateFunc : validation .IntBetween (1 , 20 ),
12051187 },
12061188
1207- "minimum_servers " : {
1208- Type : pluginsdk .TypeInt ,
1209- Optional : true ,
1210- Default : 0 ,
1189+ "host " : {
1190+ Type : pluginsdk .TypeString ,
1191+ Optional : true ,
1192+ ValidateFunc : validation . StringIsNotEmpty ,
12111193 },
12121194
12131195 // lintignore:XS003
@@ -1233,6 +1215,36 @@ func resourceApplicationGateway() *pluginsdk.Resource {
12331215 },
12341216 },
12351217
1218+ "minimum_servers" : {
1219+ Type : pluginsdk .TypeInt ,
1220+ Optional : true ,
1221+ Default : 0 ,
1222+ },
1223+
1224+ "path" : {
1225+ Type : pluginsdk .TypeString ,
1226+ Optional : true ,
1227+ ValidateFunc : validation .StringStartsWithOneOf ("/" ),
1228+ },
1229+
1230+ "pick_host_name_from_backend_http_settings" : {
1231+ Type : pluginsdk .TypeBool ,
1232+ Optional : true ,
1233+ Default : false ,
1234+ },
1235+
1236+ "port" : {
1237+ Type : pluginsdk .TypeInt ,
1238+ Optional : true ,
1239+ ValidateFunc : validate .PortNumber ,
1240+ },
1241+
1242+ "proxy_protocol_header_enabled" : {
1243+ Type : pluginsdk .TypeBool ,
1244+ Optional : true ,
1245+ Default : false ,
1246+ },
1247+
12361248 "id" : {
12371249 Type : pluginsdk .TypeString ,
12381250 Computed : true ,
@@ -3630,6 +3642,7 @@ func expandApplicationGatewayProbes(input []interface{}) *[]applicationgateways.
36303642 Timeout : pointer .To (timeout ),
36313643 UnhealthyThreshold : pointer .To (unhealthyThreshold ),
36323644 PickHostNameFromBackendHTTPSettings : pointer .To (pickHostNameFromBackendHTTPSettings ),
3645+ EnableProbeProxyProtocolHeader : pointer .To (v ["proxy_protocol_header_enabled" ].(bool )),
36333646 },
36343647 }
36353648
@@ -3711,6 +3724,8 @@ func flattenApplicationGatewayProbes(input *[]applicationgateways.ApplicationGat
37113724 output ["pick_host_name_from_backend_http_settings" ] = * pickHostNameFromBackendHTTPSettings
37123725 }
37133726
3727+ output ["proxy_protocol_header_enabled" ] = pointer .From (props .EnableProbeProxyProtocolHeader )
3728+
37143729 if minServers := props .MinServers ; minServers != nil {
37153730 output ["minimum_servers" ] = int (* minServers )
37163731 }
@@ -5391,16 +5406,44 @@ func applicationGatewayCustomizeDiff(ctx context.Context, d *pluginsdk.ResourceD
53915406 if v ["host_names" ].(* pluginsdk.Set ).Len () > 0 && strings .EqualFold (v ["protocol" ].(string ), string (applicationgateways .ApplicationGatewayProtocolTcp )) {
53925407 return fmt .Errorf ("`host_names` cannot be set when `protocol` is `Tcp` for `listener` %q" , v ["name" ].(string ))
53935408 }
5409+ if strings .EqualFold (v ["protocol" ].(string ), string (applicationgateways .ApplicationGatewayProtocolTls )) && v ["ssl_certificate_name" ].(string ) == "" {
5410+ return fmt .Errorf ("`ssl_certificate_name` must be set when `protocol` is `Tls` for `listener` %q" , v ["name" ].(string ))
5411+ }
53945412 }
53955413
53965414 for _ , raw := range d .Get ("probe" ).(* schema.Set ).List () {
53975415 v := raw .(map [string ]interface {})
5398- if v ["host" ].(string ) != "" && v ["pick_host_name_from_backend_http_settings" ].(bool ) {
5399- return fmt .Errorf ("only one of `host` or `pick_host_name_from_backend_http_settings` can be set for `probe` %q" , v ["name" ].(string ))
5416+ protocol := v ["protocol" ].(string )
5417+ isHTTPProtocol := strings .EqualFold (protocol , string (applicationgateways .ApplicationGatewayProtocolHTTP )) || strings .EqualFold (protocol , string (applicationgateways .ApplicationGatewayProtocolHTTPS ))
5418+ isTcpTlsProtocol := strings .EqualFold (protocol , string (applicationgateways .ApplicationGatewayProtocolTcp )) || strings .EqualFold (protocol , string (applicationgateways .ApplicationGatewayProtocolTls ))
5419+
5420+ hasHost := v ["host" ].(string ) != ""
5421+ hasPickHost := v ["pick_host_name_from_backend_http_settings" ].(bool )
5422+ if isHTTPProtocol && (hasHost == hasPickHost ) {
5423+ return fmt .Errorf ("exactly one of `host` or `pick_host_name_from_backend_http_settings` must be set when `protocol` is `Http` or `Https` for `probe` %q" , v ["name" ].(string ))
5424+ }
5425+
5426+ if isHTTPProtocol && v ["path" ].(string ) == "" {
5427+ return fmt .Errorf ("`path` must be specified when `protocol` is `Http` or `Https` for `probe` %q" , v ["name" ].(string ))
54005428 }
54015429
5402- if v ["path" ].(string ) != "" && (strings .EqualFold (v ["protocol" ].(string ), string (applicationgateways .ApplicationGatewayProtocolTcp )) || strings .EqualFold (v ["protocol" ].(string ), string (applicationgateways .ApplicationGatewayProtocolTls ))) {
5403- return fmt .Errorf ("`path` cannot be set when `protocol` is `Tcp` or `Tls` for `probe` %q" , v ["name" ].(string ))
5430+ if isTcpTlsProtocol {
5431+ hasPath := v ["path" ].(string ) != ""
5432+ matchConfigs := v ["match" ].([]interface {})
5433+ hasMatch := len (matchConfigs ) > 0 && matchConfigs [0 ] != nil
5434+ if hasHost || hasPickHost || hasPath || hasMatch {
5435+ return fmt .Errorf ("`host`, `pick_host_name_from_backend_http_settings`, `path`, and `match` cannot be set when `protocol` is `Tcp` or `Tls` for `probe` %q" , v ["name" ].(string ))
5436+ }
5437+ }
5438+
5439+ if v ["proxy_protocol_header_enabled" ].(bool ) && ! isTcpTlsProtocol {
5440+ return fmt .Errorf ("`proxy_protocol_header_enabled` can only be set when `protocol` is `Tcp` or `Tls` for `probe` %q" , v ["name" ].(string ))
5441+ }
5442+
5443+ timeout := v ["timeout" ].(int )
5444+ interval := v ["interval" ].(int )
5445+ if timeout > interval {
5446+ return fmt .Errorf ("`timeout` must not be greater than `interval` for `probe` %q" , v ["name" ].(string ))
54045447 }
54055448 }
54065449
@@ -5564,6 +5607,9 @@ func applicationGatewayProbeHash(v interface{}) int {
55645607 if v , ok := m ["minimum_servers" ]; ok {
55655608 buf .WriteString (fmt .Sprintf ("%d" , v .(int )))
55665609 }
5610+ if v , ok := m ["proxy_protocol_header_enabled" ]; ok {
5611+ buf .WriteString (fmt .Sprintf ("%t" , v .(bool )))
5612+ }
55675613 if match , ok := m ["match" ]; ok {
55685614 if attrs := match .([]interface {}); len (attrs ) == 1 && attrs [0 ] != nil {
55695615 attr := attrs [0 ].(map [string ]interface {})
0 commit comments