@@ -1248,6 +1248,70 @@ func TestAccELBV2Listener_attributes_alb_HTTPRequestHeaders(t *testing.T) {
1248
1248
})
1249
1249
}
1250
1250
1251
+ func TestAccELBV2Listener_attributes_alb_HTTPRequestPartialHeaders (t * testing.T ) {
1252
+ ctx := acctest .Context (t )
1253
+ var conf awstypes.Listener
1254
+ resourceName := "aws_lb_listener.test"
1255
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
1256
+
1257
+ resource .ParallelTest (t , resource.TestCase {
1258
+ PreCheck : func () { acctest .PreCheck (ctx , t ) },
1259
+ ErrorCheck : acctest .ErrorCheck (t , names .ELBV2ServiceID ),
1260
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
1261
+ CheckDestroy : testAccCheckListenerDestroy (ctx ),
1262
+ Steps : []resource.TestStep {
1263
+ {
1264
+ Config : testAccListenerConfig_attributes_albHTTPRequestPartialHeaders (rName , "https://example.com" , "DENY" ),
1265
+ Check : resource .ComposeAggregateTestCheckFunc (
1266
+ testAccCheckListenerExists (ctx , resourceName , & conf ),
1267
+ resource .TestCheckResourceAttrPair (resourceName , "load_balancer_arn" , "aws_lb.test" , names .AttrARN ),
1268
+ resource .TestCheckResourceAttr (resourceName , names .AttrProtocol , "HTTP" ),
1269
+ resource .TestCheckResourceAttr (resourceName , names .AttrPort , "80" ),
1270
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_server_enabled" , acctest .CtTrue ),
1271
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_strict_transport_security_header_value" , "max-age=31536000; includeSubDomains" ),
1272
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_origin_header_value" , "https://example.com" ),
1273
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_methods_header_value" , "GET,POST,OPTIONS" ),
1274
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_headers_header_value" , "Content-Type,X-Custom-Header" ),
1275
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_credentials_header_value" , acctest .CtTrue ),
1276
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_expose_headers_header_value" , "X-Custom-Header" ),
1277
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_max_age_header_value" , "3600" ),
1278
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_content_security_policy_header_value" , "default-src 'self'" ),
1279
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_x_content_type_options_header_value" , "nosniff" ),
1280
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_x_frame_options_header_value" , "DENY" ),
1281
+ ),
1282
+ },
1283
+ {
1284
+ ResourceName : resourceName ,
1285
+ ImportState : true ,
1286
+ ImportStateVerify : true ,
1287
+ ImportStateVerifyIgnore : []string {
1288
+ "default_action.0.forward" ,
1289
+ },
1290
+ },
1291
+ {
1292
+ Config : testAccListenerConfig_attributes_albHTTPRequestPartialHeaders (rName , "https://www.example.com" , "SAMEORIGIN" ),
1293
+ Check : resource .ComposeAggregateTestCheckFunc (
1294
+ testAccCheckListenerExists (ctx , resourceName , & conf ),
1295
+ resource .TestCheckResourceAttrPair (resourceName , "load_balancer_arn" , "aws_lb.test" , names .AttrARN ),
1296
+ resource .TestCheckResourceAttr (resourceName , names .AttrProtocol , "HTTP" ),
1297
+ resource .TestCheckResourceAttr (resourceName , names .AttrPort , "80" ),
1298
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_server_enabled" , acctest .CtTrue ),
1299
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_strict_transport_security_header_value" , "max-age=31536000; includeSubDomains" ),
1300
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_origin_header_value" , "https://www.example.com" ),
1301
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_methods_header_value" , "GET,POST,OPTIONS" ),
1302
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_headers_header_value" , "Content-Type,X-Custom-Header" ),
1303
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_allow_credentials_header_value" , acctest .CtTrue ),
1304
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_expose_headers_header_value" , "X-Custom-Header" ),
1305
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_access_control_max_age_header_value" , "3600" ),
1306
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_content_security_policy_header_value" , "default-src 'self'" ),
1307
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_x_content_type_options_header_value" , "nosniff" ),
1308
+ resource .TestCheckResourceAttr (resourceName , "routing_http_response_x_frame_options_header_value" , "SAMEORIGIN" ),
1309
+ ),
1310
+ },
1311
+ },
1312
+ })
1313
+ }
1314
+
1251
1315
func TestAccELBV2Listener_attributes_alb_HTTPSRequestHeaders (t * testing.T ) {
1252
1316
ctx := acctest .Context (t )
1253
1317
var conf awstypes.Listener
@@ -3312,6 +3376,59 @@ resource "aws_lb_target_group" "test" {
3312
3376
` , rName , allowOriginHeaderValue , frameOptionsHeaderValue ))
3313
3377
}
3314
3378
3379
+ func testAccListenerConfig_attributes_albHTTPRequestPartialHeaders (rName , allowOriginHeaderValue , frameOptionsHeaderValue string ) string {
3380
+ return acctest .ConfigCompose (
3381
+ testAccListenerConfig_base (rName ), fmt .Sprintf (`
3382
+ resource "aws_lb_listener" "test" {
3383
+ load_balancer_arn = aws_lb.test.arn
3384
+ protocol = "HTTP"
3385
+ port = 80
3386
+
3387
+ routing_http_response_strict_transport_security_header_value = "max-age=31536000; includeSubDomains"
3388
+ routing_http_response_access_control_allow_origin_header_value = %[2]q
3389
+ routing_http_response_access_control_allow_methods_header_value = "GET,POST,OPTIONS"
3390
+ routing_http_response_access_control_allow_headers_header_value = "Content-Type,X-Custom-Header"
3391
+ routing_http_response_access_control_allow_credentials_header_value = "true"
3392
+ routing_http_response_access_control_expose_headers_header_value = "X-Custom-Header"
3393
+ routing_http_response_access_control_max_age_header_value = "3600"
3394
+ routing_http_response_content_security_policy_header_value = "default-src 'self'"
3395
+ routing_http_response_x_content_type_options_header_value = "nosniff"
3396
+ routing_http_response_x_frame_options_header_value = %[3]q
3397
+
3398
+ default_action {
3399
+ type = "forward"
3400
+ target_group_arn = aws_lb_target_group.test.arn
3401
+ }
3402
+ }
3403
+
3404
+ resource "aws_lb" "test" {
3405
+ name = %[1]q
3406
+ internal = true
3407
+ load_balancer_type = "application"
3408
+ security_groups = [aws_security_group.test.id]
3409
+ subnets = aws_subnet.test[*].id
3410
+
3411
+ idle_timeout = 30
3412
+ enable_deletion_protection = false
3413
+
3414
+ tags = {
3415
+ Name = %[1]q
3416
+ }
3417
+ }
3418
+
3419
+ resource "aws_lb_target_group" "test" {
3420
+ name = %[1]q
3421
+ port = 80
3422
+ protocol = "HTTP"
3423
+ vpc_id = aws_vpc.test.id
3424
+
3425
+ tags = {
3426
+ Name = %[1]q
3427
+ }
3428
+ }
3429
+ ` , rName , allowOriginHeaderValue , frameOptionsHeaderValue ))
3430
+ }
3431
+
3315
3432
func testAccListenerConfig_attributes_albHTTPSRequestHeaders (rName , key , certificate string ) string {
3316
3433
return acctest .ConfigCompose (
3317
3434
testAccListenerConfig_base (rName ), fmt .Sprintf (`
0 commit comments