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:
Allen Sanborn committed 2026-09-01 14:35:30 -05:00
1 parent 910e64e726
commit 9bf93b94c2
2 files changed
+38 -5

No files matched your search

@@ -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");