floci-io/floci · error · AwsException
ValidationError
ValidationError
Error message
Valid requests must contain either the InstanceID parameter or both the ImageId and InstanceType parameters.
What it means
Thrown by the Auto Scaling emulator's createLaunchConfiguration when neither InstanceId nor the pair (ImageId, InstanceType) is supplied. AWS requires a launch source: either clone a running EC2 instance by ID, or specify an AMI plus instance type. Missing both yields ValidationError / HTTP 400.
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingService.java:84
private <V> Map<String, V> storageBacked(String fileName, TypeReference<Map<String, V>> typeReference)
{
return new StorageBackedMap<>(storageFactory.create("autoscaling", fileName, typeReference));
}
// ── Launch Configurations ──────────────────────────────────────────────────
public LaunchConfiguration createLaunchConfiguration(String region, String name, String instanceId,
String imageId, String instanceType, String keyName,
List<String> securityGroups, String userData,
String iamInstanceProfile,
Boolean associatePublicIpAddress) {
String key = lcKey(region, name);
if (launchConfigs.containsKey(key)) {
throw new AwsException("AlreadyExists",
"Launch configuration '" + name + "' already exists.", 400);
}
if (isBlank(instanceId) && (isBlank(imageId) || isBlank(instanceType))) {
throw new AwsException("ValidationError", INVALID_LAUNCH_CONFIGURATION_PARAMETERS_MESSAGE, 400);
}
if (notBlank(instanceId) && ec2Service != null) {
List<Instance> sourceInstances = ec2Service.describeInstances(region, List.of(instanceId), Map.of())
.stream()
.flatMap(reservation -> reservation.getInstances().stream())
.collect(Collectors.toList());
if (!sourceInstances.isEmpty()) {
Instance source = sourceInstances.getFirst();
if (isBlank(imageId)) {
imageId = source.getImageId();
}
if (isBlank(instanceType)) {
instanceType = source.getInstanceType();
}
if (isBlank(keyName)) {
keyName = source.getKeyName();
}
if ((securityGroups == null || securityGroups.isEmpty())View on GitHub (pinned to 62ff490619)
Solutions
- Provide both --image-id and --instance-type.
- Or provide --instance-id to copy image/type/key/security groups from a running instance.
- Validate your template variables render non-empty before applying.
- If you pass InstanceId, ensure the EC2 emulator knows that instance.
Example fix
# before aws autoscaling create-launch-configuration --launch-configuration-name web # after aws autoscaling create-launch-configuration \ --launch-configuration-name web \ --image-id ami-1234567890abcdef0 \ --instance-type t3.micro
Defensive patterns
Strategy: validation
Validate before calling
static void validateLaunchSource(String instanceId, String imageId, String instanceType) {
boolean hasInstance = instanceId != null && !instanceId.isBlank();
boolean hasPair = (imageId != null && !imageId.isBlank()) && (instanceType != null && !instanceType.isBlank());
if (!hasInstance && !hasPair)
throw new IllegalArgumentException(
"Provide InstanceId, or both ImageId and InstanceType");
} Prevention
- Validate the image/instance-type pair together — one without the other always fails.
- Lint IaC templates for empty interpolated values in launch configuration blocks.
- When cloning from InstanceId, confirm the instance exists in the EC2 emulator first.
When it happens
Trigger: createLaunchConfiguration called with only a name (e.g. aws autoscaling create-launch-configuration --launch-configuration-name web), or with ImageId but no InstanceType (or vice versa); templates where one parameter failed to interpolate.
Common situations: Terraform/CloudFormation templates with empty variable values; scripts where instance_type is conditionally empty; refactoring from instance-clone to image-based config and dropping one field.
Understand the failure class
Background: ValidationError explained: why open-source libraries reject your input — file uploads, YAML manifests, unique fields, and query permissions — this error's family across 13 libraries.
Related errors
- AlreadyExists
- ValidationError
- TLS enabled but no certificate provided and self-signed gene
- ValidationException
- ValidationException
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/5ee9087abc262a97.
Report an issue: GitHub.