feat(autoscaling): warm pools, scheduled actions, traffic sources, and process suspension (#2973)

* feat(autoscaling): warm pools, scheduled actions, traffic sources, and process suspension

PutWarmPool/DescribeWarmPool/DeleteWarmPool, PutScheduledUpdateGroupAction/
DescribeScheduledActions/DeleteScheduledAction, AttachTrafficSources/
DetachTrafficSources/DescribeTrafficSources, and SuspendProcesses/
ResumeProcesses, parsed against botocore's autoscaling/2011-01-01 wire model.
Deleting a group also removes its scheduled actions and warm pool.

* fix(autoscaling): scope scheduled-action cleanup to the group's region

Deleting a group removed scheduled actions with the same group name in every region. PutScheduledUpdateGroupAction now rejects a malformed StartTime or EndTime with ValidationError instead of treating it as absent.
This commit is contained in:
lex00 authored and GitHub committed 2026-09-04 09:30:25 -04:00
1 parent 84ec8ae8e7
commit 09801146b1
8 files changed
+939 -5

No files matched your search

@@ -11,8 +11,10 @@ import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.jboss.logging.Logger;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
@ApplicationScoped
@@ -44,6 +46,11 @@ public class AutoScalingQueryHandler {
case "DeleteAutoScalingGroup" -> handleDeleteAutoScalingGroup(p, region);
case "DescribeAutoScalingGroups" -> handleDescribeAutoScalingGroups(p, region);
case "SetDesiredCapacity" -> handleSetDesiredCapacity(p, region);
case "SuspendProcesses" -> handleSuspendProcesses(p, region);
case "ResumeProcesses" -> handleResumeProcesses(p, region);
case "PutWarmPool" -> handlePutWarmPool(p, region);
case "DescribeWarmPool" -> handleDescribeWarmPool(p, region);
case "DeleteWarmPool" -> handleDeleteWarmPool(p, region);
case "StartInstanceRefresh" -> handleStartInstanceRefresh(p, region);
case "DescribeInstanceRefreshes" -> handleDescribeInstanceRefreshes(p, region);
case "CreateOrUpdateTags" -> handleCreateOrUpdateTags(p, region);
@@ -62,6 +69,9 @@ public class AutoScalingQueryHandler {
case "AttachLoadBalancers" -> handleAttachLoadBalancers(p, region);
case "DetachLoadBalancers" -> handleDetachLoadBalancers(p, region);
case "DescribeLoadBalancers" -> handleDescribeLoadBalancers(p, region);
case "AttachTrafficSources" -> handleAttachTrafficSources(p, region);
case "DetachTrafficSources" -> handleDetachTrafficSources(p, region);
case "DescribeTrafficSources" -> handleDescribeTrafficSources(p, region);
// Lifecycle hooks
case "PutLifecycleHook" -> handlePutLifecycleHook(p, region);
case "DeleteLifecycleHook" -> handleDeleteLifecycleHook(p, region);
@@ -72,6 +82,9 @@ public class AutoScalingQueryHandler {
case "PutScalingPolicy" -> handlePutScalingPolicy(p, region);
case "DeletePolicy" -> handleDeletePolicy(p, region);
case "DescribePolicies" -> handleDescribePolicies(p, region);
case "PutScheduledUpdateGroupAction" -> handlePutScheduledUpdateGroupAction(p, region);
case "DeleteScheduledAction" -> handleDeleteScheduledAction(p, region);
case "DescribeScheduledActions" -> handleDescribeScheduledActions(p, region);
// Activities
case "DescribeScalingActivities" -> handleDescribeScalingActivities(p, region);
// Metadata
@@ -267,6 +280,11 @@ public class AutoScalingQueryHandler {
xml.end("LaunchTemplate");
}
appendMixedInstancesPolicyXml(xml, asg.getMixedInstancesPolicy());
// Botocore's own AutoScalingGroup shape documents WarmPoolConfiguration as a member of
// DescribeAutoScalingGroups' response, not only reachable via DescribeWarmPool -
// terraform-aws-autoscaling's warm_pool example reads the group's warm pool state this
// way. Shared with handleDescribeWarmPool so the two never drift.
appendWarmPoolConfigurationXml(xml, service.describeWarmPool(asg.getRegion(), asg.getAutoScalingGroupName()));
xml.start("AvailabilityZones");
for (String az : asg.getAvailabilityZones()) { xml.elem("member", az); }
@@ -288,6 +306,12 @@ public class AutoScalingQueryHandler {
for (String tp : asg.getTerminationPolicies()) { xml.elem("member", tp); }
xml.end("TerminationPolicies");
xml.start("SuspendedProcesses");
for (String sp : asg.getSuspendedProcesses()) {
xml.start("member").elem("ProcessName", sp).end("member");
}
xml.end("SuspendedProcesses");
xml.start("Instances");
for (AsgInstance inst : asg.getInstances()) {
xml.start("member")
@@ -1144,6 +1168,218 @@ public class AutoScalingQueryHandler {
try { return Integer.parseInt(val); } catch (NumberFormatException e) { return defaultValue; }
}
// ── Suspend/resume scaling processes ────────────────────────────────────
private Response handleSuspendProcesses(MultivaluedMap<String, String> p, String region) {
service.suspendProcesses(region,
p.getFirst("AutoScalingGroupName"),
memberList(p, "ScalingProcesses"));
return ok(new XmlBuilder()
.start("SuspendProcessesResponse", NS)
.raw(AwsQueryResponse.responseMetadata())
.end("SuspendProcessesResponse").build());
}
private Response handleResumeProcesses(MultivaluedMap<String, String> p, String region) {
service.resumeProcesses(region,
p.getFirst("AutoScalingGroupName"),
memberList(p, "ScalingProcesses"));
return ok(new XmlBuilder()
.start("ResumeProcessesResponse", NS)
.raw(AwsQueryResponse.responseMetadata())
.end("ResumeProcessesResponse").build());
}
// ── Warm pools ──────────────────────────────────────────────────────────
// Parsed against botocore's autoscaling/2011-01-01/service-2.json
// (PutWarmPoolType, DescribeWarmPoolType, DescribeWarmPoolAnswer,
// DeleteWarmPoolType, WarmPoolConfiguration, InstanceReusePolicy) rather than
// docs prose - see AutoScalingService's warm-pool section for the
// full-replace-with-defaults rationale behind PutWarmPool's parsing here.
private Response handlePutWarmPool(MultivaluedMap<String, String> p, String region) {
service.putWarmPool(region,
p.getFirst("AutoScalingGroupName"),
nullableIntParam(p, "MaxGroupPreparedCapacity"),
nullableIntParam(p, "MinSize"),
p.getFirst("PoolState"),
nullableBoolParam(p, "InstanceReusePolicy.ReuseOnScaleIn"));
return ok(new XmlBuilder()
.start("PutWarmPoolResponse", NS)
.start("PutWarmPoolResult").end("PutWarmPoolResult")
.raw(AwsQueryResponse.responseMetadata())
.end("PutWarmPoolResponse").build());
}
private Response handleDescribeWarmPool(MultivaluedMap<String, String> p, String region) {
WarmPoolConfiguration pool = service.describeWarmPool(region, p.getFirst("AutoScalingGroupName"));
XmlBuilder xml = new XmlBuilder()
.start("DescribeWarmPoolResponse", NS)
.start("DescribeWarmPoolResult");
appendWarmPoolConfigurationXml(xml, pool);
xml.start("Instances").end("Instances")
.end("DescribeWarmPoolResult")
.raw(AwsQueryResponse.responseMetadata())
.end("DescribeWarmPoolResponse");
return ok(xml.build());
}
private static void appendWarmPoolConfigurationXml(XmlBuilder xml, WarmPoolConfiguration pool) {
if (pool == null) {
return;
}
xml.start("WarmPoolConfiguration");
if (pool.getMaxGroupPreparedCapacity() != null) {
xml.elem("MaxGroupPreparedCapacity", String.valueOf(pool.getMaxGroupPreparedCapacity()));
}
xml.elem("MinSize", String.valueOf(pool.getMinSize()))
.elem("PoolState", pool.getPoolState())
.start("InstanceReusePolicy")
.elem("ReuseOnScaleIn", String.valueOf(pool.isReuseOnScaleIn()))
.end("InstanceReusePolicy")
.end("WarmPoolConfiguration");
}
private Response handleDeleteWarmPool(MultivaluedMap<String, String> p, String region) {
service.deleteWarmPool(region,
p.getFirst("AutoScalingGroupName"),
"true".equalsIgnoreCase(p.getFirst("ForceDelete")));
return ok(new XmlBuilder()
.start("DeleteWarmPoolResponse", NS)
.start("DeleteWarmPoolResult").end("DeleteWarmPoolResult")
.raw(AwsQueryResponse.responseMetadata())
.end("DeleteWarmPoolResponse").build());
}
// ── Traffic sources ─────────────────────────────────────────────────────
// AWS's own DescribeTrafficSources doc page example shows a bare, unwrapped
// <TrafficSources> element per item, which reads as a flattened list - but
// botocore's actual service-2.json models the TrafficSources list WITHOUT
// "flattened": true and with member locationName "member" like every other
// list in this API, so the wire shape is the normal
// <TrafficSources><member>...</member></TrafficSources>. The doc page's
// example was simply wrong; trusting it verbatim left the AWS provider's own
// post-create waiter polling DescribeTrafficSources and never finding the
// resource it had just attached - the actual wire format, not the docs, is
// the source of truth here.
private Response handleAttachTrafficSources(MultivaluedMap<String, String> p, String region) {
service.attachTrafficSources(region, p.getFirst("AutoScalingGroupName"), parseTrafficSources(p));
return ok(new XmlBuilder()
.start("AttachTrafficSourcesResponse", NS)
.start("AttachTrafficSourcesResult").end("AttachTrafficSourcesResult")
.raw(AwsQueryResponse.responseMetadata())
.end("AttachTrafficSourcesResponse").build());
}
private Response handleDetachTrafficSources(MultivaluedMap<String, String> p, String region) {
service.detachTrafficSources(region, p.getFirst("AutoScalingGroupName"), parseTrafficSources(p));
return ok(new XmlBuilder()
.start("DetachTrafficSourcesResponse", NS)
.start("DetachTrafficSourcesResult").end("DetachTrafficSourcesResult")
.raw(AwsQueryResponse.responseMetadata())
.end("DetachTrafficSourcesResponse").build());
}
private Response handleDescribeTrafficSources(MultivaluedMap<String, String> p, String region) {
Map<String, String> sources = service.describeTrafficSources(region,
p.getFirst("AutoScalingGroupName"), p.getFirst("TrafficSourceType"));
XmlBuilder xml = new XmlBuilder()
.start("DescribeTrafficSourcesResponse", NS)
.start("DescribeTrafficSourcesResult")
.start("TrafficSources");
sources.forEach((identifier, type) -> xml.start("member")
.elem("Identifier", identifier)
.elem("State", "InService")
.elem("Type", type)
.end("member"));
xml.end("TrafficSources")
.end("DescribeTrafficSourcesResult")
.raw(AwsQueryResponse.responseMetadata())
.end("DescribeTrafficSourcesResponse");
return ok(xml.build());
}
private List<AutoScalingService.TrafficSourceIdentifier> parseTrafficSources(MultivaluedMap<String, String> p) {
List<AutoScalingService.TrafficSourceIdentifier> result = new ArrayList<>();
for (int i = 1; ; i++) {
String identifier = p.getFirst("TrafficSources.member." + i + ".Identifier");
if (identifier == null) { break; }
String type = p.getFirst("TrafficSources.member." + i + ".Type");
result.add(new AutoScalingService.TrafficSourceIdentifier(identifier, type));
}
return result;
}
// ── Scheduled actions ───────────────────────────────────────────────────
private Response handlePutScheduledUpdateGroupAction(MultivaluedMap<String, String> p, String region) {
service.putScheduledUpdateGroupAction(region,
p.getFirst("AutoScalingGroupName"),
p.getFirst("ScheduledActionName"),
parseInstant("StartTime", p.getFirst("StartTime")),
parseInstant("EndTime", p.getFirst("EndTime")),
p.getFirst("Recurrence"),
p.getFirst("TimeZone"),
nullableIntParam(p, "MinSize"),
nullableIntParam(p, "MaxSize"),
nullableIntParam(p, "DesiredCapacity"));
return ok(new XmlBuilder()
.start("PutScheduledUpdateGroupActionResponse", NS)
.start("PutScheduledUpdateGroupActionResult").end("PutScheduledUpdateGroupActionResult")
.raw(AwsQueryResponse.responseMetadata())
.end("PutScheduledUpdateGroupActionResponse").build());
}
private Response handleDeleteScheduledAction(MultivaluedMap<String, String> p, String region) {
service.deleteScheduledAction(region,
p.getFirst("AutoScalingGroupName"), p.getFirst("ScheduledActionName"));
return ok(new XmlBuilder()
.start("DeleteScheduledActionResponse", NS)
.raw(AwsQueryResponse.responseMetadata())
.end("DeleteScheduledActionResponse").build());
}
private Response handleDescribeScheduledActions(MultivaluedMap<String, String> p, String region) {
List<ScheduledAction> actions = service.describeScheduledActions(
region, p.getFirst("AutoScalingGroupName"), memberList(p, "ScheduledActionNames"));
XmlBuilder xml = new XmlBuilder()
.start("DescribeScheduledActionsResponse", NS)
.start("DescribeScheduledActionsResult")
.start("ScheduledUpdateGroupActions");
for (ScheduledAction action : actions) {
xml.start("member")
.elem("ScheduledActionName", action.getScheduledActionName())
.elem("ScheduledActionARN", action.getScheduledActionArn())
.elem("AutoScalingGroupName", action.getAutoScalingGroupName());
if (action.getStartTime() != null) { xml.elem("StartTime", ISO_FMT.format(action.getStartTime())); }
if (action.getEndTime() != null) { xml.elem("EndTime", ISO_FMT.format(action.getEndTime())); }
if (action.getRecurrence() != null) { xml.elem("Recurrence", action.getRecurrence()); }
if (action.getTimeZone() != null) { xml.elem("TimeZone", action.getTimeZone()); }
if (action.getMinSize() != null) { xml.elem("MinSize", String.valueOf(action.getMinSize())); }
if (action.getMaxSize() != null) { xml.elem("MaxSize", String.valueOf(action.getMaxSize())); }
if (action.getDesiredCapacity() != null) {
xml.elem("DesiredCapacity", String.valueOf(action.getDesiredCapacity()));
}
xml.end("member");
}
xml.end("ScheduledUpdateGroupActions")
.end("DescribeScheduledActionsResult")
.raw(AwsQueryResponse.responseMetadata())
.end("DescribeScheduledActionsResponse");
return ok(xml.build());
}
private Instant parseInstant(String name, String value) {
if (value == null || value.isBlank()) { return null; }
try {
return Instant.parse(value);
} catch (DateTimeParseException e) {
throw new AwsException("ValidationError",
name + " '" + value + "' is not a valid ISO 8601 timestamp.", 400);
}
}
private Integer nullableIntParam(MultivaluedMap<String, String> p, String key) {
String val = p.getFirst(key);
if (val == null || val.isBlank()) { return null; }
@@ -49,6 +49,8 @@ public class AutoScalingService {
private Map<String, ScalingPolicy> policies = new ConcurrentHashMap<>();
private Map<String, ScalingActivity> activities = new ConcurrentHashMap<>();
private Map<String, InstanceRefresh> instanceRefreshes = new ConcurrentHashMap<>();
private Map<String, ScheduledAction> scheduledActions = new ConcurrentHashMap<>();
private Map<String, WarmPoolConfiguration> warmPools = new ConcurrentHashMap<>();
@PostConstruct
void initializeStorage()
@@ -62,6 +64,8 @@ public class AutoScalingService {
this.policies = storageBacked("autoscaling-policies.json", new TypeReference<Map<String, ScalingPolicy>>() {});
this.activities = storageBacked("autoscaling-activities.json", new TypeReference<Map<String, ScalingActivity>>() {});
this.instanceRefreshes = storageBacked("autoscaling-instance-refreshes.json", new TypeReference<Map<String, InstanceRefresh>>() {});
this.scheduledActions = storageBacked("autoscaling-scheduled-actions.json", new TypeReference<Map<String, ScheduledAction>>() {});
this.warmPools = storageBacked("autoscaling-warm-pools.json", new TypeReference<Map<String, WarmPoolConfiguration>>() {});
}
private <V> Map<String, V> storageBacked(String fileName, TypeReference<Map<String, V>> typeReference)
@@ -302,6 +306,9 @@ public class AutoScalingService {
hooks.entrySet().removeIf(e -> e.getValue().getAutoScalingGroupName().equals(name));
policies.entrySet().removeIf(e -> e.getValue().getAutoScalingGroupName().equals(name));
instanceRefreshes.entrySet().removeIf(e -> e.getValue().getAutoScalingGroupName().equals(name));
scheduledActions.entrySet().removeIf(e -> region.equals(e.getValue().getRegion())
&& name.equals(e.getValue().getAutoScalingGroupName()));
warmPools.remove(warmPoolKey(region, name));
}
public List<AutoScalingGroup> describeAutoScalingGroups(String region, List<String> names) {
@@ -358,6 +365,38 @@ public class AutoScalingService {
return requireGroup(region, resourceId);
}
// Real AWS suspends the named scaling processes ("Launch", "Terminate", "HealthCheck", ...)
// so they stop running until resumed; an empty list suspends all of them. Floci has no
// scaling loop for these processes to pause, so this only needs to record which processes
// are suspended for DescribeAutoScalingGroups to report back - the same "accept and
// remember" shape as terminationPolicies. The AWS provider calls this unconditionally
// around ASG creation whenever wait_for_capacity_timeout is non-zero (the default), so an
// unimplemented SuspendProcesses fails ASG creation outright, not just a feature gap.
private static final List<String> ALL_SCALING_PROCESSES = List.of(
"Launch", "Terminate", "AddToLoadBalancer", "AlarmNotification", "AZRebalance",
"HealthCheck", "InstanceRefresh", "ReplaceUnhealthy", "ScheduledActions");
public void suspendProcesses(String region, String name, List<String> processes) {
AutoScalingGroup asg = requireGroup(region, name);
List<String> toSuspend = processes.isEmpty() ? ALL_SCALING_PROCESSES : processes;
Set<String> suspended = new LinkedHashSet<>(asg.getSuspendedProcesses());
suspended.addAll(toSuspend);
asg.setSuspendedProcesses(new ArrayList<>(suspended));
groups.put(asgKey(region, name), asg);
}
public void resumeProcesses(String region, String name, List<String> processes) {
AutoScalingGroup asg = requireGroup(region, name);
if (processes.isEmpty()) {
asg.setSuspendedProcesses(new ArrayList<>());
} else {
List<String> remaining = new ArrayList<>(asg.getSuspendedProcesses());
remaining.removeAll(processes);
asg.setSuspendedProcesses(remaining);
}
groups.put(asgKey(region, name), asg);
}
// ── Instance management ────────────────────────────────────────────────────
public List<AsgInstance> describeAutoScalingInstances(String region, List<String> instanceIds) {
@@ -604,6 +643,47 @@ public class AutoScalingService {
groups.put(asgKey(region, name), asg);
}
// ── Traffic sources ─────────────────────────────────────────────────────────────
// AttachTrafficSources/DetachTrafficSources/DescribeTrafficSources is the modern,
// unified ASG-to-load-balancer wiring API (elb, elbv2, vpc-lattice), which
// aws_autoscaling_traffic_source_attachment uses instead of the older
// AttachLoadBalancerTargetGroups. "accept and remember" like the target-group
// attachment above - Floci has no real health-checking loop, so every attached
// traffic source is reported InService immediately.
public record TrafficSourceIdentifier(String identifier, String type) {}
public void attachTrafficSources(String region, String name, List<TrafficSourceIdentifier> sources) {
AutoScalingGroup asg = requireGroup(region, name);
for (TrafficSourceIdentifier source : sources) {
asg.getTrafficSourceTypeByIdentifier().put(source.identifier(),
source.type() != null ? source.type() : "elbv2");
}
groups.put(asgKey(region, name), asg);
}
public void detachTrafficSources(String region, String name, List<TrafficSourceIdentifier> sources) {
AutoScalingGroup asg = requireGroup(region, name);
for (TrafficSourceIdentifier source : sources) {
asg.getTrafficSourceTypeByIdentifier().remove(source.identifier());
}
groups.put(asgKey(region, name), asg);
}
public Map<String, String> describeTrafficSources(String region, String name, String trafficSourceType) {
Map<String, String> all = requireGroup(region, name).getTrafficSourceTypeByIdentifier();
if (trafficSourceType == null || trafficSourceType.isBlank()) {
return all;
}
Map<String, String> filtered = new LinkedHashMap<>();
all.forEach((identifier, type) -> {
if (trafficSourceType.equals(type)) {
filtered.put(identifier, type);
}
});
return filtered;
}
// ── Lifecycle hooks ────────────────────────────────────────────────────────
public void putLifecycleHook(String region, String asgName, String hookName,
@@ -753,6 +833,112 @@ public class AutoScalingService {
.collect(Collectors.toList());
}
// ── Scheduled actions ───────────────────────────────────────────────────
// PutScheduledUpdateGroupAction/DescribeScheduledActions/DeleteScheduledAction -
// aws_autoscaling_schedule's whole lifecycle. Floci has no cron scheduler to
// actually run these, so - same "accept and remember" shape as scaling
// policies above - this only needs to record and read back the schedule
// definition itself; the AWS provider's own Read never expects a scheduled
// action to have fired inside an emulator.
public ScheduledAction putScheduledUpdateGroupAction(String region, String asgName, String actionName,
Instant startTime, Instant endTime, String recurrence,
String timeZone, Integer minSize, Integer maxSize,
Integer desiredCapacity) {
requireGroup(region, asgName);
String key = scheduledActionKey(region, asgName, actionName);
ScheduledAction action = scheduledActions.computeIfAbsent(key, k -> new ScheduledAction());
action.setScheduledActionName(actionName);
action.setAutoScalingGroupName(asgName);
action.setScheduledActionArn(AwsArnUtils.Arn.of("autoscaling", region, regionResolver.getAccountId(),
"scheduledUpdateGroupAction:" + asgName + ":" + actionName).toString());
action.setStartTime(startTime);
action.setEndTime(endTime);
action.setRecurrence(recurrence);
action.setTimeZone(timeZone);
action.setMinSize(minSize);
action.setMaxSize(maxSize);
action.setDesiredCapacity(desiredCapacity);
action.setRegion(region);
scheduledActions.put(key, action);
return action;
}
public void deleteScheduledAction(String region, String asgName, String actionName) {
scheduledActions.remove(scheduledActionKey(region, asgName, actionName));
}
public List<ScheduledAction> describeScheduledActions(String region, String asgName, List<String> actionNames) {
return scheduledActions.values().stream()
.filter(a -> region.equals(a.getRegion()))
.filter(a -> asgName == null || asgName.equals(a.getAutoScalingGroupName()))
.filter(a -> actionNames == null || actionNames.isEmpty() || actionNames.contains(a.getScheduledActionName()))
.collect(Collectors.toList());
}
private static String scheduledActionKey(String region, String asgName, String actionName) {
return region + "::" + asgName + "::" + actionName;
}
// ── Warm pools ──────────────────────────────────────────────────────────
// PutWarmPool/DescribeWarmPool/DeleteWarmPool - aws_autoscaling_group's
// warm_pool block. Verified directly against botocore's
// autoscaling/2011-01-01/service-2.json wire model rather than docs prose:
// PutWarmPoolType/DeleteWarmPoolType/DescribeWarmPoolType
// and their *Answer response shapes, WarmPoolConfiguration, WarmPoolState,
// InstanceReusePolicy. PutWarmPool is a full replace: MinSize's own shape
// doc says "Defaults to 0 if not specified" and PoolState's says "Default is
// Stopped" - an omitted field resets to that default, it does not carry the
// prior value forward, which is why putWarmPool always rebuilds the
// configuration from scratch rather than mutating the stored one in place.
// MaxGroupPreparedCapacity has no default (absent unless set), and the shape
// doc calls out -1 as the caller's own documented sentinel for "clear a
// previously-set value" - not a real capacity, so it maps back to null and
// is never rendered as -1.
//
// Floci has no scaling loop that actually launches pre-initialized instances
// into the pool, so DescribeWarmPool's own Instances list is always empty
// and WarmPoolConfiguration.Status ("PendingDelete") is never set - the
// "accept and remember" shape scaling policies and scheduled actions above
// already use for AWS features with no local reconciler. DeleteWarmPool
// removes the stored configuration outright and is silently idempotent when
// no warm pool exists, matching deletePolicy above rather than throwing.
public WarmPoolConfiguration putWarmPool(String region, String asgName,
Integer maxGroupPreparedCapacity,
Integer minSize,
String poolState,
Boolean reuseOnScaleIn) {
requireGroup(region, asgName);
WarmPoolConfiguration pool = new WarmPoolConfiguration();
pool.setAutoScalingGroupName(asgName);
pool.setRegion(region);
// -1 is the wire model's own documented sentinel for "remove a
// previously-set value" - not a literal capacity.
pool.setMaxGroupPreparedCapacity(
maxGroupPreparedCapacity != null && maxGroupPreparedCapacity != -1
? maxGroupPreparedCapacity : null);
pool.setMinSize(minSize != null ? minSize : 0);
pool.setPoolState(poolState != null && !poolState.isBlank() ? poolState : "Stopped");
pool.setReuseOnScaleIn(Boolean.TRUE.equals(reuseOnScaleIn));
warmPools.put(warmPoolKey(region, asgName), pool);
return pool;
}
public WarmPoolConfiguration describeWarmPool(String region, String asgName) {
requireGroup(region, asgName);
return warmPools.get(warmPoolKey(region, asgName));
}
public void deleteWarmPool(String region, String asgName, boolean forceDelete) {
requireGroup(region, asgName);
warmPools.remove(warmPoolKey(region, asgName));
}
private static String warmPoolKey(String region, String asgName) {
return region + "::" + asgName;
}
// ── Scaling activities ─────────────────────────────────────────────────────
public List<ScalingActivity> describeScalingActivities(String region, String asgName) {
@@ -32,6 +32,11 @@ public class AutoScalingGroup {
private int healthCheckGracePeriod = 0;
private List<AsgInstance> instances = new ArrayList<>();
private List<String> terminationPolicies = new ArrayList<>();
private List<String> suspendedProcesses = new ArrayList<>();
// AttachTrafficSources (the modern elbv2/vpc-lattice ASG-to-load-balancer wiring API,
// which aws_autoscaling_traffic_source_attachment uses instead of the older
// AttachLoadBalancerTargetGroups) - identifier -> type ("elbv2", "elb", "vpc-lattice").
private Map<String, String> trafficSourceTypeByIdentifier = new ConcurrentHashMap<>();
private Instant createdTime;
private String region;
private Map<String, String> tags = new ConcurrentHashMap<>();
@@ -97,6 +102,12 @@ public class AutoScalingGroup {
public List<String> getTerminationPolicies() { return terminationPolicies; }
public void setTerminationPolicies(List<String> v) { this.terminationPolicies = v; }
public List<String> getSuspendedProcesses() { return suspendedProcesses; }
public void setSuspendedProcesses(List<String> v) { this.suspendedProcesses = v; }
public Map<String, String> getTrafficSourceTypeByIdentifier() { return trafficSourceTypeByIdentifier; }
public void setTrafficSourceTypeByIdentifier(Map<String, String> v) { this.trafficSourceTypeByIdentifier = v; }
public Instant getCreatedTime() { return createdTime; }
public void setCreatedTime(Instant v) { this.createdTime = v; }
@@ -0,0 +1,58 @@
package io.github.hectorvent.floci.services.autoscaling.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class ScheduledAction {
private String scheduledActionName;
private String scheduledActionArn;
private String autoScalingGroupName;
private Instant startTime;
private Instant endTime;
private String recurrence;
private String timeZone;
private Integer minSize;
private Integer maxSize;
private Integer desiredCapacity;
private String region;
public ScheduledAction() {}
public String getScheduledActionName() { return scheduledActionName; }
public void setScheduledActionName(String v) { this.scheduledActionName = v; }
public String getScheduledActionArn() { return scheduledActionArn; }
public void setScheduledActionArn(String v) { this.scheduledActionArn = v; }
public String getAutoScalingGroupName() { return autoScalingGroupName; }
public void setAutoScalingGroupName(String v) { this.autoScalingGroupName = v; }
public Instant getStartTime() { return startTime; }
public void setStartTime(Instant v) { this.startTime = v; }
public Instant getEndTime() { return endTime; }
public void setEndTime(Instant v) { this.endTime = v; }
public String getRecurrence() { return recurrence; }
public void setRecurrence(String v) { this.recurrence = v; }
public String getTimeZone() { return timeZone; }
public void setTimeZone(String v) { this.timeZone = v; }
public Integer getMinSize() { return minSize; }
public void setMinSize(Integer v) { this.minSize = v; }
public Integer getMaxSize() { return maxSize; }
public void setMaxSize(Integer v) { this.maxSize = v; }
public Integer getDesiredCapacity() { return desiredCapacity; }
public void setDesiredCapacity(Integer v) { this.desiredCapacity = v; }
public String getRegion() { return region; }
public void setRegion(String v) { this.region = v; }
}
@@ -0,0 +1,46 @@
package io.github.hectorvent.floci.services.autoscaling.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* A warm pool attached to an Auto Scaling group (PutWarmPool/DescribeWarmPool/
* DeleteWarmPool). PutWarmPool is a full replace, not a merge - per botocore's
* own documentation on MinSize ("Defaults to 0 if not specified") and PoolState
* ("Default is Stopped"), a Put that omits a field resets it to that field's
* declared default rather than leaving a prior value in place. MaxGroupPreparedCapacity
* is the one field with no default: absent unless the caller sets it, and a caller
* passing exactly -1 clears a previously-set value back to absent (the wire model's
* own documented sentinel for "unset this").
*/
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class WarmPoolConfiguration {
private String autoScalingGroupName;
private Integer maxGroupPreparedCapacity;
private int minSize;
private String poolState = "Stopped";
private boolean reuseOnScaleIn;
private String region;
public WarmPoolConfiguration() {}
public String getAutoScalingGroupName() { return autoScalingGroupName; }
public void setAutoScalingGroupName(String v) { this.autoScalingGroupName = v; }
public Integer getMaxGroupPreparedCapacity() { return maxGroupPreparedCapacity; }
public void setMaxGroupPreparedCapacity(Integer v) { this.maxGroupPreparedCapacity = v; }
public int getMinSize() { return minSize; }
public void setMinSize(int v) { this.minSize = v; }
public String getPoolState() { return poolState; }
public void setPoolState(String v) { this.poolState = v; }
public boolean isReuseOnScaleIn() { return reuseOnScaleIn; }
public void setReuseOnScaleIn(boolean v) { this.reuseOnScaleIn = v; }
public String getRegion() { return region; }
public void setRegion(String v) { this.region = v; }
}