mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ec2): read RunInstances security groups from the primary interface spec (#6964)
* fix(ec2): read RunInstances security groups from the primary interface spec RunInstances read security groups only from the top-level SecurityGroupId.N. With private_ip or associate_public_ip_address set, Terraform's aws_instance sends them on the primary interface spec (NetworkInterface.1.SecurityGroupId.N), so the instance landed in the VPC's default group and the next plan wanted to replace it. The interface spec's groups apply only when its DeviceIndex is 0 (another index is a secondary interface), and a request carrying both shapes fails with InvalidParameterCombination, as on AWS. * test(ec2): match the capacity reservation argument RunInstances now passes * test(ec2): fold the interface security group cases into Ec2RunInstancesPublicIpParamTest Both classes tested what RunInstances takes from the interface spec with the same handler setup, base params and runInstances stub; only the captured argument differed. One forward() helper now runs the request and captures both the security groups and the public-IP override, and the separate class is gone.
This commit is contained in:
1 parent
8aa7bc98ad
commit
8dbcf6bf17
3 files changed
+77
-26
No files matched your search
@@ -821,6 +821,19 @@ public class Ec2QueryHandler {
|
||||
int networkInterfaceDeviceIndex = parseIntParam(p, "NetworkInterface.1.DeviceIndex", 0);
|
||||
String clientToken = p.getFirst("ClientToken");
|
||||
List<String> sgIds = getList(p, "SecurityGroupId");
|
||||
// With a primary interface spec the groups travel on it: Terraform's aws_instance sends that
|
||||
// shape whenever private_ip or associate_public_ip_address is set. A spec with another device
|
||||
// index is a secondary interface, whose groups are not the instance's.
|
||||
List<String> interfaceSgIds = networkInterfaceDeviceIndex == 0
|
||||
? getList(p, "NetworkInterface.1.SecurityGroupId") : List.of();
|
||||
if (!interfaceSgIds.isEmpty()) {
|
||||
if (!sgIds.isEmpty()) {
|
||||
throw new AwsException("InvalidParameterCombination",
|
||||
"Network interfaces and an instance-level security groups may not be specified on "
|
||||
+ "the same request", 400);
|
||||
}
|
||||
sgIds = interfaceSgIds;
|
||||
}
|
||||
|
||||
// UserData is base64-encoded in the wire format
|
||||
String userDataEncoded = p.getFirst("UserData");
|
||||
|
||||
Reference in new issue
Block a user