diff --git a/docs/services/lambda.md b/docs/services/lambda.md index f3b5cd6a6f..221ef25251 100644 --- a/docs/services/lambda.md +++ b/docs/services/lambda.md @@ -970,7 +970,7 @@ rather than echoing the request back: | Field | Request shape | Response shape | Extra members Floci fills in | |---|---|---|---| -| `VpcConfig` | `VpcConfig` | `VpcConfigResponse` | `VpcId`, resolved from the first subnet via EC2 | +| `VpcConfig` | `VpcConfig` | `VpcConfigResponse` | `VpcId`, shared by all declared subnets and security groups | | `SnapStart` | `SnapStart` | `SnapStartResponse` | `OptimizationStatus` — `On` only for a published version with `ApplyOn=PublishedVersions`, `Off` for `$LATEST` | | `LoggingConfig` | `LoggingConfig` | `LoggingConfig` | — | | `DurableConfig` | `DurableConfig` | `DurableConfig` | `RetentionPeriodInDays` defaults to 14; omitted for a function created without it | @@ -1009,9 +1009,19 @@ on create and on update with `InvalidParameterValueException` ("LogLevel is not LogFormat is set to "Text". Remove LogLevel from your request or change the LogFormat to "JSON" and try again."), as Lambda refuses it (measured in eu-west-1, 2026-10-18). -`VpcConfig` is omitted entirely while the function is not attached to a VPC. -Subnets that EC2 does not know about are still accepted and returned; only `VpcId` -is left off in that case. +`VpcConfig` accepts placeholder subnet and security-group IDs that are unknown in +Floci's request account and region. This local compatibility behavior preserves the +requested IDs but omits `VpcId` whenever any requested resource is unknown. Known +subnets and security groups must still belong to one VPC, even when the request also +contains unknown IDs. Mixed known VPCs or specifying only subnets or only security +groups fail with `InvalidParameterValueException` before the function is mutated. +A rejected update preserves the configuration and revision. Empty subnet and security +group lists detach the function, and the response then omits `VpcConfig`. Published +versions retain their network configuration when `$LATEST` changes. + +These checks validate the declaration. Function containers still use the configured +Docker network; `VpcConfig` does not yet enforce VPC packet routing, security-group +rules, or NAT egress. `RuntimeVersionConfig.RuntimeVersionArn` is returned for managed (non-image) runtimes. Its value is derived from the runtime name, so it is stable across diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java index a96f5bca69..dfdaf88bd1 100644 --- a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java +++ b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java @@ -22,6 +22,7 @@ import io.github.hectorvent.floci.core.resource.SupportedResourceType; import io.github.hectorvent.floci.core.storage.StorageBackedMap; import io.github.hectorvent.floci.core.storage.StorageFactory; import io.github.hectorvent.floci.services.ec2.Ec2Service; +import io.github.hectorvent.floci.services.ec2.model.SecurityGroup; import io.github.hectorvent.floci.services.ec2.model.Subnet; import io.github.hectorvent.floci.services.iam.AccessDeniedMessages.PolicyType; import io.github.hectorvent.floci.services.lambda.durable.DurableExecutionService; @@ -78,6 +79,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * Business logic for Lambda function management and invocation. @@ -243,6 +245,18 @@ public class LambdaService implements ResourceProvider { EmulatorConfig config, RegionResolver regionResolver, StorageFactory storageFactory) { + this(functionStore, warmPool, codeStore, zipExtractor, config, regionResolver, storageFactory, null); + } + + /** Package-private constructor for tests that attach functions to EC2 resources. */ + LambdaService(LambdaFunctionStore functionStore, + WarmPool warmPool, + CodeStore codeStore, + ZipExtractor zipExtractor, + EmulatorConfig config, + RegionResolver regionResolver, + StorageFactory storageFactory, + Ec2Service ec2Service) { this.functionStore = functionStore; this.executorService = null; this.concurrencyLimiter = new LambdaConcurrencyLimiter(); @@ -261,7 +275,7 @@ public class LambdaService implements ResourceProvider { this.dynamodbStreamsPoller = null; this.storageFactory = storageFactory; this.layerService = null; - this.ec2Service = null; + this.ec2Service = ec2Service; this.customResourceLiveness = null; this.durableExecutionService = null; this.codeSigningConfigService = storageFactory == null @@ -1039,8 +1053,10 @@ public class LambdaService implements ResourceProvider { ? validatedConfigurationInteger(request.get("Timeout"), "Timeout", 1, 900) : 0; Map requestedVpcConfig = fn.getVpcConfig(); + String requestedVpcId = fn.getVpcId(); if (requestedVpcConfigUpdate != null) { requestedVpcConfig = new HashMap<>(requestedVpcConfigUpdate); + requestedVpcId = resolveVpcId(region, requestedVpcConfig); } List requestedFileSystemConfigs = fn.getFileSystemConfigs(); if (request.containsKey("FileSystemConfigs")) { @@ -1111,7 +1127,7 @@ public class LambdaService implements ResourceProvider { if (request.containsKey("VpcConfig")) { if (requestedVpcConfigUpdate != null) { fn.setVpcConfig(requestedVpcConfig); - fn.setVpcId(resolveVpcId(region, requestedVpcConfig)); + fn.setVpcId(requestedVpcId); } } @@ -2718,30 +2734,54 @@ public class LambdaService implements ResourceProvider { } } - /** - * The VpcConfig request shape carries no VpcId; VpcConfigResponse does. AWS derives it from - * the subnets the function is attached to, so resolve it once at attach time and store it. - * A subnet EC2 has never heard of resolves to null rather than failing the call - Floci's - * Lambda accepts unmanaged subnet ids, and CreateFunction must not start rejecting them. - */ + /** Resolve the common VPC only after every requested subnet and security group is validated. */ private String resolveVpcId(String region, Map vpcConfig) { - if (ec2Service == null || !hasValues(vpcConfig, "SubnetIds")) { + List subnetIds = vpcResourceIds(vpcConfig, "SubnetIds"); + List groupIds = vpcResourceIds(vpcConfig, "SecurityGroupIds"); + if (subnetIds.isEmpty() && groupIds.isEmpty()) { return null; } - for (Object subnetId : (List) vpcConfig.get("SubnetIds")) { - if (subnetId == null) { - continue; - } - try { - List found = ec2Service.describeSubnets(region, List.of(subnetId.toString()), Map.of()); - if (!found.isEmpty() && found.get(0).getVpcId() != null) { - return found.get(0).getVpcId(); - } - } catch (RuntimeException e) { - LOG.debugv(e, "Could not resolve VpcId for subnet {0} in {1}", subnetId, region); - } + if (subnetIds.isEmpty() || groupIds.isEmpty()) { + throw new AwsException("InvalidParameterValueException", + "VpcConfig requires both subnet IDs and security group IDs", 400); } - return null; + if (ec2Service == null) { + return null; + } + List subnets = ec2Service.describeSubnets(region, subnetIds, Map.of()); + List groups = ec2Service.describeSecurityGroups(region, groupIds, List.of(), Map.of()); + Set knownVpcIds = subnets.stream().map(Subnet::getVpcId).collect(Collectors.toSet()); + groups.stream().map(SecurityGroup::getVpcId).forEach(knownVpcIds::add); + if (knownVpcIds.contains(null) || knownVpcIds.size() > 1) { + throw new AwsException("InvalidParameterValueException", + "All known subnets and security groups in VpcConfig must belong to the same VPC", 400); + } + if (!Set.copyOf(subnetIds).equals( + subnets.stream().map(Subnet::getSubnetId).collect(Collectors.toSet())) + || !Set.copyOf(groupIds).equals( + groups.stream().map(SecurityGroup::getGroupId).collect(Collectors.toSet()))) { + return null; + } + return knownVpcIds.stream().findFirst().orElse(null); + } + + private static List vpcResourceIds(Map vpcConfig, String member) { + Object value = vpcConfig == null ? null : vpcConfig.get(member); + if (value == null) { + return List.of(); + } + if (!(value instanceof List list)) { + throw new AwsException("SerializationException", "VpcConfig." + member + " must be an array", 400); + } + List ids = new ArrayList<>(list.size()); + for (Object id : list) { + if (!(id instanceof String resourceId)) { + throw new AwsException("SerializationException", + "VpcConfig." + member + " must contain strings", 400); + } + ids.add(resourceId); + } + return ids; } private static Map structureMember(Map request, String member) { diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcResourceValidationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcResourceValidationIntegrationTest.java new file mode 100644 index 0000000000..65726af0e3 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcResourceValidationIntegrationTest.java @@ -0,0 +1,248 @@ +package io.github.hectorvent.floci.services.lambda; + +import io.quarkus.test.common.http.TestHTTPResource; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.core.SdkBytes; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.ec2.Ec2Client; +import software.amazon.awssdk.services.iam.IamClient; +import software.amazon.awssdk.services.lambda.LambdaClient; +import software.amazon.awssdk.services.lambda.model.FunctionCode; +import software.amazon.awssdk.services.lambda.model.GetFunctionConfigurationResponse; +import software.amazon.awssdk.services.lambda.model.InvalidParameterValueException; +import software.amazon.awssdk.services.lambda.model.ResourceNotFoundException; +import software.amazon.awssdk.services.lambda.model.Runtime; +import software.amazon.awssdk.services.lambda.model.VpcConfig; +import software.amazon.awssdk.services.lambda.model.VpcConfigResponse; + +import java.io.ByteArrayOutputStream; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@QuarkusTest +class LambdaVpcResourceValidationIntegrationTest { + + private final String name = "vpc-validation-" + UUID.randomUUID().toString().substring(0, 8); + private final List cleanup = new ArrayList<>(); + private Ec2Client ec2; + private IamClient iam; + private LambdaClient lambda; + private Network first; + private Network second; + private String roleArn; + private FunctionCode code; + + @TestHTTPResource("/") + URI endpoint; + + @BeforeEach + void createDeclaredNetworksAndRole() throws Exception { + StaticCredentialsProvider credentials = StaticCredentialsProvider.create( + AwsBasicCredentials.create("test", "test")); + ec2 = Ec2Client.builder().region(Region.US_EAST_1).endpointOverride(endpoint) + .credentialsProvider(credentials).build(); + iam = IamClient.builder().region(Region.US_EAST_1).endpointOverride(endpoint) + .credentialsProvider(credentials).build(); + lambda = LambdaClient.builder().region(Region.US_EAST_1).endpointOverride(endpoint) + .credentialsProvider(credentials).build(); + first = network("10.90"); + second = network("10.91"); + roleArn = iam.createRole(r -> r.roleName(name).assumeRolePolicyDocument(""" + {"Version":"2012-10-17","Statement":[{"Effect":"Allow", + "Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]} + """)).role().arn(); + cleanup.add(() -> iam.deleteRole(r -> r.roleName(name))); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (ZipOutputStream zip = new ZipOutputStream(bytes)) { + zip.putNextEntry(new ZipEntry("index.js")); + zip.write("exports.handler = async event => event;".getBytes(StandardCharsets.UTF_8)); + zip.closeEntry(); + } + code = FunctionCode.builder().zipFile(SdkBytes.fromByteArray(bytes.toByteArray())).build(); + cleanup.add(() -> { + try { + lambda.deleteFunction(r -> r.functionName(name)); + } catch (ResourceNotFoundException ignored) { + // A rejected create must leave no function to delete. + } + }); + } + + @AfterEach + void removeOwnedResources() { + try { + Collections.reverse(cleanup); + assertAll(cleanup); + } finally { + if (lambda != null) { + lambda.close(); + } + if (iam != null) { + iam.close(); + } + if (ec2 != null) { + ec2.close(); + } + } + } + + @ParameterizedTest + @ValueSource(strings = {"mixed-subnets", "mixed-groups", "only-subnets", "only-groups", + "unknown-with-mixed-subnets", "unknown-with-mixed-groups"}) + void invalidVpcResourcesCannotCreateAFunction(String kind) { + VpcConfig config = switch (kind) { + case "mixed-subnets" -> VpcConfig.builder().subnetIds(first.subnet(), second.subnet()) + .securityGroupIds(first.group()).build(); + case "mixed-groups" -> VpcConfig.builder().subnetIds(first.subnet()) + .securityGroupIds(first.group(), second.group()).build(); + case "unknown-with-mixed-subnets" -> VpcConfig.builder() + .subnetIds(first.subnet(), "subnet-fffffffffffffffff", second.subnet()) + .securityGroupIds(first.group()).build(); + case "unknown-with-mixed-groups" -> VpcConfig.builder() + .subnetIds("subnet-fffffffffffffffff") + .securityGroupIds(first.group(), "sg-fffffffffffffffff", second.group()).build(); + case "only-subnets" -> VpcConfig.builder().subnetIds(first.subnet()).build(); + case "only-groups" -> VpcConfig.builder().securityGroupIds(first.group()).build(); + default -> throw new IllegalArgumentException(kind); + }; + InvalidParameterValueException failure = assertThrows( + InvalidParameterValueException.class, () -> createFunction(config)); + assertEquals(400, failure.statusCode()); + assertThrows(ResourceNotFoundException.class, + () -> lambda.getFunctionConfiguration(r -> r.functionName(name))); + } + + @ParameterizedTest + @ValueSource(strings = {"both", "subnet", "group", "second-subnet", "second-group"}) + void unknownVpcIdsRoundTripWithoutAnInferredVpc(String kind) { + VpcConfig config = switch (kind) { + case "both" -> VpcConfig.builder().subnetIds("subnet-fffffffffffffffff") + .securityGroupIds("sg-fffffffffffffffff").build(); + case "subnet" -> VpcConfig.builder().subnetIds("subnet-fffffffffffffffff") + .securityGroupIds(first.group()).build(); + case "group" -> VpcConfig.builder().subnetIds(first.subnet()) + .securityGroupIds("sg-fffffffffffffffff").build(); + case "second-subnet" -> VpcConfig.builder().subnetIds(first.subnet(), "subnet-fffffffffffffffff") + .securityGroupIds(first.group()).build(); + case "second-group" -> VpcConfig.builder().subnetIds(first.subnet()) + .securityGroupIds(first.group(), "sg-fffffffffffffffff").build(); + default -> throw new IllegalArgumentException(kind); + }; + createFunction(config); + assertEquals(config.subnetIds(), configuration().vpcConfig().subnetIds()); + assertEquals(config.securityGroupIds(), configuration().vpcConfig().securityGroupIds()); + assertNull(configuration().vpcConfig().vpcId()); + } + + @Test + void unknownVpcUpdateClearsOnlyTheLatestInferredVpc() { + createFunction(first.config()); + String version = lambda.publishVersion(r -> r.functionName(name)).version(); + VpcConfig placeholders = VpcConfig.builder().subnetIds("subnet-fffffffffffffffff") + .securityGroupIds("sg-fffffffffffffffff").build(); + lambda.updateFunctionConfiguration(r -> r.functionName(name).description("updated") + .vpcConfig(placeholders)); + assertEquals("updated", configuration().description()); + assertEquals(placeholders.subnetIds(), configuration().vpcConfig().subnetIds()); + assertEquals(placeholders.securityGroupIds(), configuration().vpcConfig().securityGroupIds()); + assertNull(configuration().vpcConfig().vpcId()); + assertNetwork(first, lambda.getFunctionConfiguration( + r -> r.functionName(name).qualifier(version)).vpcConfig()); + } + + @Test + void rejectedVpcUpdatePreservesTheExistingConfigurationAndRevision() { + createFunction(first.config()); + GetFunctionConfigurationResponse before = configuration(); + + InvalidParameterValueException failure = assertThrows(InvalidParameterValueException.class, + () -> lambda.updateFunctionConfiguration(r -> r.functionName(name) + .description("must-not-change").timeout(30).memorySize(256) + .vpcConfig(VpcConfig.builder().subnetIds(first.subnet(), second.subnet()) + .securityGroupIds(first.group()).build()))); + + assertEquals(400, failure.statusCode()); + GetFunctionConfigurationResponse after = configuration(); + assertEquals(before.vpcConfig(), after.vpcConfig()); + assertEquals(before.description(), after.description()); + assertEquals(before.timeout(), after.timeout()); + assertEquals(before.memorySize(), after.memorySize()); + assertEquals(before.revisionId(), after.revisionId()); + assertEquals(before.lastModified(), after.lastModified()); + } + + @Test + void validVpcUpdatePreservesThePublishedVersionsNetwork() { + createFunction(first.config()); + String version = lambda.publishVersion(r -> r.functionName(name)).version(); + lambda.updateFunctionConfiguration(r -> r.functionName(name).vpcConfig(second.config())); + + assertNetwork(second, configuration().vpcConfig()); + assertNetwork(first, lambda.getFunctionConfiguration( + r -> r.functionName(name).qualifier(version)).vpcConfig()); + } + + @Test + void emptySubnetAndGroupListsDetachTheFunction() { + createFunction(first.config()); + lambda.updateFunctionConfiguration(r -> r.functionName(name) + .vpcConfig(VpcConfig.builder().subnetIds(List.of()).securityGroupIds(List.of()).build())); + + VpcConfigResponse current = configuration().vpcConfig(); + assertTrue(current == null || (!current.hasSubnetIds() && !current.hasSecurityGroupIds() + && (current.vpcId() == null || current.vpcId().isEmpty()))); + } + + private Network network(String prefix) { + String vpc = ec2.createVpc(r -> r.cidrBlock(prefix + ".0.0/16")).vpc().vpcId(); + cleanup.add(() -> ec2.deleteVpc(r -> r.vpcId(vpc))); + String subnet = ec2.createSubnet(r -> r.vpcId(vpc).cidrBlock(prefix + ".1.0/24")).subnet().subnetId(); + cleanup.add(() -> ec2.deleteSubnet(r -> r.subnetId(subnet))); + String group = ec2.createSecurityGroup( + r -> r.vpcId(vpc).groupName(name).description("Declared Lambda network")).groupId(); + cleanup.add(() -> ec2.deleteSecurityGroup(r -> r.groupId(group))); + return new Network(vpc, subnet, group); + } + + private void createFunction(VpcConfig config) { + lambda.createFunction(r -> r.functionName(name).runtime(Runtime.NODEJS22_X) + .role(roleArn).handler("index.handler").code(code).description("original") + .timeout(9).memorySize(128).vpcConfig(config)); + } + + private GetFunctionConfigurationResponse configuration() { + return lambda.getFunctionConfiguration(r -> r.functionName(name)); + } + + private static void assertNetwork(Network expected, VpcConfigResponse actual) { + assertEquals(expected.vpc(), actual.vpcId()); + assertEquals(List.of(expected.subnet()), actual.subnetIds()); + assertEquals(List.of(expected.group()), actual.securityGroupIds()); + } + + private record Network(String vpc, String subnet, String group) { + private VpcConfig config() { + return VpcConfig.builder().subnetIds(subnet).securityGroupIds(group).build(); + } + } +} diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java index d33ab83e0e..25473b4359 100644 --- a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaVpcSnapStartLoggingIntegrationTest.java @@ -31,7 +31,6 @@ class LambdaVpcSnapStartLoggingIntegrationTest { private static final String BASE_PATH = "/2015-03-31"; private static final String REGION = "us-east-1"; - private static final String SECURITY_GROUP_ID = "sg-0123456789abcdef0"; private static final String LOG_LEVEL_UNDER_TEXT = "LogLevel is not supported when LogFormat is set to \"Text\". " + "Remove LogLevel from your request or change the LogFormat to \"JSON\" and try again."; @@ -40,12 +39,14 @@ class LambdaVpcSnapStartLoggingIntegrationTest { private String subnetId; private String expectedVpcId; + private String securityGroupId; @BeforeEach void resolveSubnet() { Subnet subnet = ec2Service.describeSubnets(REGION, List.of(), Map.of()).get(0); subnetId = subnet.getSubnetId(); expectedVpcId = subnet.getVpcId(); + securityGroupId = ec2Service.defaultSecurityGroupOf(REGION, expectedVpcId).orElseThrow().getGroupId(); } private void createFunction(String name, String extraJson) { @@ -80,7 +81,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { "VpcConfig": { "SubnetIds": ["%s"], "SecurityGroupIds": ["%s"] - }""".formatted(subnetId, SECURITY_GROUP_ID); + }""".formatted(subnetId, securityGroupId); } @Test @@ -100,7 +101,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { .then() .statusCode(201) .body("VpcConfig.SubnetIds", contains(subnetId)) - .body("VpcConfig.SecurityGroupIds", contains(SECURITY_GROUP_ID)) + .body("VpcConfig.SecurityGroupIds", contains(securityGroupId)) .body("VpcConfig.VpcId", equalTo(expectedVpcId)) .body("VpcConfig.Ipv6AllowedForDualStack", equalTo(false)); } @@ -115,7 +116,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { .then() .statusCode(200) .body("VpcConfig.SubnetIds", contains(subnetId)) - .body("VpcConfig.SecurityGroupIds", contains(SECURITY_GROUP_ID)) + .body("VpcConfig.SecurityGroupIds", contains(securityGroupId)) .body("VpcConfig.VpcId", equalTo(expectedVpcId)); } @@ -129,7 +130,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { .then() .statusCode(200) .body("Configuration.VpcConfig.SubnetIds", contains(subnetId)) - .body("Configuration.VpcConfig.SecurityGroupIds", contains(SECURITY_GROUP_ID)) + .body("Configuration.VpcConfig.SecurityGroupIds", contains(securityGroupId)) .body("Configuration.VpcConfig.VpcId", equalTo(expectedVpcId)); } @@ -146,7 +147,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { "SecurityGroupIds": ["%s"] } } - """.formatted(subnetId, SECURITY_GROUP_ID)) + """.formatted(subnetId, securityGroupId)) .when() .put(BASE_PATH + "/functions/vpc-update-fn/configuration") .then() @@ -160,7 +161,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { .then() .statusCode(200) .body("VpcConfig.SubnetIds", contains(subnetId)) - .body("VpcConfig.SecurityGroupIds", contains(SECURITY_GROUP_ID)) + .body("VpcConfig.SecurityGroupIds", contains(securityGroupId)) .body("VpcConfig.VpcId", equalTo(expectedVpcId)); } @@ -183,7 +184,7 @@ class LambdaVpcSnapStartLoggingIntegrationTest { "VpcConfig": { "SubnetIds": ["subnet-ffffffffffffffff0"], "SecurityGroupIds": ["%s"] - }""".formatted(SECURITY_GROUP_ID)); + }""".formatted(securityGroupId)); given() .when()