fix(ec2): name launch template network interface groups groupId on the wire (#7138)

LaunchTemplateInstanceNetworkInterfaceSpecification.Groups is a GroupIdStringList
whose members are named groupId, not item. aws-sdk-go-v2 reads only groupId, so
Terraform saw security_groups as empty and planned an update every time.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-31 21:54:32 -05:00
1 parent 89ecb594e1
commit 52055654a7
2 files changed
+7 -2

No files matched your search

@@ -5758,7 +5758,7 @@ public class Ec2QueryHandler {
if (!networkInterface.getGroups().isEmpty()) {
xml.start("groupSet");
for (String group : networkInterface.getGroups()) {
xml.elem("item", group);
xml.elem("groupId", group);
}
xml.end("groupSet");
}
@@ -12,6 +12,7 @@ import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Regression tests for CreateLaunchTemplate discarding nearly all of RequestLaunchTemplateData.
@@ -199,8 +200,12 @@ class Ec2LaunchTemplateFieldsIntegrationTest {
.body(DATA + "networkInterfaceSet.item.subnetId", equalTo("subnet-0123456789abcdef0"))
.body(DATA + "networkInterfaceSet.item.associatePublicIpAddress", equalTo("true"))
.body(DATA + "networkInterfaceSet.item.deleteOnTermination", equalTo("true"))
.body(DATA + "networkInterfaceSet.item.groupSet.item",
.body(DATA + "networkInterfaceSet.item.groupSet.groupId",
contains("sg-1111111111111111a", "sg-2222222222222222b"));
// GroupIdStringList members are named groupId on the wire; aws-sdk-go-v2 reads only that tag.
String raw = describeBody(name);
assertTrue(raw.contains("<groupSet><groupId>sg-1111111111111111a</groupId>"), raw);
assertFalse(raw.contains("<groupSet><item>"), raw);
// Not promoted to the top level: that promotion is what made the block disappear.
assertFalse(describeBody(name).contains("securityGroupIdSet"),
"interface groups must not be hoisted into top-level SecurityGroupIds");