mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(elbv2): drop access logs from a Gateway Load Balancer's attributes
Only deletion_protection.enabled and load_balancing.cross_zone.enabled are supported by every load balancer type; access_logs.s3.* is an Application and Network Load Balancer attribute. Adding it unconditionally handed a Gateway Load Balancer a schema AWS never returns for one, which is as wrong as omitting a key that does belong.
This commit is contained in:
1 parent
910e64e726
commit
9bf93b94c2
2 files changed
+38
-5
No files matched your search
+12
-5
@@ -29,14 +29,21 @@ final class ElbV2DefaultAttributes {
|
||||
static Map<String, String> forLoadBalancer(LoadBalancer lb) {
|
||||
String type = lb.getType() == null ? "application" : lb.getType().toLowerCase();
|
||||
Map<String, String> defaults = new LinkedHashMap<>();
|
||||
// Supported by every type: deletion protection and cross-zone load balancing, and nothing
|
||||
// else. Cross-zone is on for an ALB and off for the others, which is the one default that
|
||||
// differs by type rather than the key simply not existing.
|
||||
defaults.put("deletion_protection.enabled", "false");
|
||||
defaults.put("access_logs.s3.enabled", "false");
|
||||
defaults.put("access_logs.s3.bucket", "");
|
||||
defaults.put("access_logs.s3.prefix", "");
|
||||
// Cross-zone load balancing is on for an ALB and off for the others, which is the one
|
||||
// default that differs by type rather than the key simply not existing.
|
||||
defaults.put("load_balancing.cross_zone.enabled", "application".equals(type) ? "true" : "false");
|
||||
|
||||
// Access logs are an Application and Network Load Balancer attribute. A Gateway Load
|
||||
// Balancer does not have them, and reporting them for one would hand a client a schema
|
||||
// AWS never returns.
|
||||
if ("application".equals(type) || "network".equals(type)) {
|
||||
defaults.put("access_logs.s3.enabled", "false");
|
||||
defaults.put("access_logs.s3.bucket", "");
|
||||
defaults.put("access_logs.s3.prefix", "");
|
||||
}
|
||||
|
||||
if ("application".equals(type)) {
|
||||
defaults.put("idle_timeout.timeout_seconds", "60");
|
||||
defaults.put("client_keep_alive.seconds", "3600");
|
||||
|
||||
+26
@@ -106,6 +106,32 @@ class ElbV2DefaultAttributesIntegrationTest {
|
||||
not(hasItem("idle_timeout.timeout_seconds")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Access logs are an Application and Network Load Balancer attribute. A Gateway Load Balancer
|
||||
* has only the two every type shares, and reporting more would hand a client a schema AWS
|
||||
* never returns for it.
|
||||
*/
|
||||
@Test
|
||||
void aGatewayLoadBalancerGetsOnlyTheAttributesEveryTypeShares() {
|
||||
String arn = createLoadBalancer("attrs-gwlb", "gateway", "10.100.");
|
||||
|
||||
given()
|
||||
.formParam("Action", "DescribeLoadBalancerAttributes")
|
||||
.formParam("LoadBalancerArn", arn)
|
||||
.header("Authorization", AUTH)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("DescribeLoadBalancerAttributesResponse.DescribeLoadBalancerAttributesResult.Attributes.member.Key",
|
||||
hasItem("deletion_protection.enabled"))
|
||||
.body("DescribeLoadBalancerAttributesResponse.DescribeLoadBalancerAttributesResult.Attributes.member.find { it.Key == 'load_balancing.cross_zone.enabled' }.Value",
|
||||
equalTo("false"))
|
||||
.body("DescribeLoadBalancerAttributesResponse.DescribeLoadBalancerAttributesResult.Attributes.member.Key",
|
||||
not(hasItem("access_logs.s3.enabled")))
|
||||
.body("DescribeLoadBalancerAttributesResponse.DescribeLoadBalancerAttributesResult.Attributes.member.Key",
|
||||
not(hasItem("idle_timeout.timeout_seconds")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aModifiedAttributeWinsOverItsDefaultAndTheRestStillReport() {
|
||||
String arn = createLoadBalancer("attrs-modified", "application", "10.99.");
|
||||
|
||||
Reference in new issue
Block a user