Light, fluffy, and always free - The AWS Local Emulator alternative
fix(lambda): carry the owning account into published version snapshots (#2041)
TiMf4e8bd8edfd8
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.javaindex c1dea94957..613776f2b7 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@@ -928,6 +928,7 @@ public class LambdaService {functionName = fn.getFunctionName();int version = nextVersionNumber(region + "::" + functionName);LambdaFunction snapshot = new LambdaFunction();+ snapshot.setAccountId(fn.getAccountId());snapshot.setFunctionName(fn.getFunctionName());snapshot.setVersion(String.valueOf(version));snapshot.setFunctionArn(fn.getFunctionArn().replace(":$LATEST", "") + ":" + version);diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.javaindex 4043ab2b3e..9dfcb638a5 100644--- a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java@@ -241,6 +241,21 @@ class LambdaServiceTest {return Base64.getEncoder().encodeToString(baos.toByteArray());}+ @Test+ void publishVersionCarriesTheOwningAccount() {+ service.createFunction(REGION, baseRequest("account-versioned-fn"));++ LambdaFunction version = service.publishVersion(REGION, "account-versioned-fn", null);++ // A version snapshot is built field by field, so anything reading accountId off it (the+ // deployment-package key, execution-role session ownership) otherwise has to re-derive the+ // account from the ARN or fall back to the default account.+ assertEquals("000000000000", version.getAccountId());+ assertEquals(+ service.getFunction(REGION, "account-versioned-fn").getAccountId(),+ version.getAccountId());+ }+@Testvoid createFunctionWithSubdirectoryHandler() throws Exception {Map<String, Object> req = new java.util.HashMap<>(Map.of(