fix(lambda): reject provisioned concurrency for SnapStart versions (#6433)

* fix(lambda): reject provisioned concurrency for SnapStart versions

Reject provisioned concurrency admission and configured alias retargeting for published SnapStart versions before mutation. Preserve older version snapshots and unconfigured alias behavior.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

* test(lambda): remove redundant SnapStart SDK fixture

Retain the pool regressions and existing alias retarget SDK coverage as requested in review. Remove the duplicate SDK case and its custom zip construction.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>

---------

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-10-24 17:54:59 -04:00
1 parent 922e36a472
commit 01b388eca9
3 files changed
+74

No files matched your search

+6
View File
@@ -454,6 +454,12 @@ rejects one outright with `InvalidParameterValueException: Invalid layer version
## Provisioned concurrency
Published versions with `SnapStart.ApplyOn=PublishedVersions` reject provisioned concurrency
with `ResourceConflictException`, including through an alias. A configured alias cannot
retarget to such a version. Eligibility uses the published snapshot, so changing `$LATEST`
does not change older versions. Get and Delete retain their normal configuration lookup
behavior, and unconfigured aliases can still point to SnapStart versions.
Put, Get and Delete use `/2019-09-30/functions/{FunctionName}/provisioned-concurrency`
with a required `Qualifier` query parameter. Put accepts a positive integer
`ProvisionedConcurrentExecutions` and returns HTTP 202 with `IN_PROGRESS`. An existing
@@ -496,6 +496,10 @@ public class ProvisionedConcurrencyPool implements Resettable {
}
private static void validateSupportedTarget(LambdaFunction fn) {
if ("PublishedVersions".equals(fn.getSnapStartApplyOn())) {
throw new AwsException("ResourceConflictException", "The operation cannot be performed at this time. "
+ "Provisioned Concurrency is not supported for SnapStart enabled functions", 409);
}
if (fn.isHotReload() || fn.isDurable()) {
throw invalid("Provisioned concurrency is not supported for hot-reload or durable functions");
}
@@ -102,6 +102,70 @@ class ProvisionedConcurrencyPoolTest {
return pool.put(REGION, "example", "live", count, ACCOUNT);
}
@ParameterizedTest
@CsvSource({"1, None", "live, None", "1, PublishedVersions", "live, PublishedVersions"})
void snapStartEligibilityUsesThePublishedSnapshot(String qualifier, String latestApplyOn) {
version.setSnapStartApplyOn("PublishedVersions");
functions.getForAccount(ACCOUNT, REGION, "example").orElseThrow().setSnapStartApplyOn(latestApplyOn);
AwsException error = assertThrows(AwsException.class,
() -> pool.put(REGION, "example", qualifier, 1, ACCOUNT));
assertSnapStartConflict(error);
assertTrue(storage.scanAllAccounts().isEmpty());
assertEquals("ProvisionedConcurrencyConfigNotFoundException",
assertThrows(AwsException.class, () -> pool.get(REGION, "example", qualifier, ACCOUNT)).getErrorCode());
assertDoesNotThrow(() -> pool.delete(REGION, "example", qualifier, ACCOUNT));
}
@ParameterizedTest
@ValueSource(strings = {"1", "live"})
void latestSnapStartDoesNotDisqualifyAnOlderVersion(String qualifier) {
functions.getForAccount(ACCOUNT, REGION, "example").orElseThrow().setSnapStartApplyOn("PublishedVersions");
assertEquals(1, pool.put(REGION, "example", qualifier, 1, ACCOUNT).requested());
assertEquals(1, pool.put(REGION, "example", qualifier, 1, ACCOUNT).requested());
}
@Test
void provisionedAliasCannotRetargetToASnapStartVersion() {
function(ACCOUNT, REGION, "2").setSnapStartApplyOn("PublishedVersions");
put(1);
assertSnapStartConflict(assertThrows(AwsException.class,
() -> pool.validateAliasUpdate(version, "live", "2")));
assertEquals("1", storage.scanAllAccounts().getFirst().version());
assertEquals(1, get().requested());
assertDoesNotThrow(() -> pool.validateAliasUpdate(version, "live", null));
assertDoesNotThrow(() -> pool.validateAliasUpdate(version, "unconfigured", "2"));
pool.delete(REGION, "example", "live", ACCOUNT);
assertDoesNotThrow(() -> pool.validateAliasUpdate(version, "live", "2"));
}
@Test
void aliasSnapStartValidationUsesTheFunctionOwnerAndRegion() {
function(ACCOUNT, REGION, "2");
String owner = "222222222222";
String region = "eu-west-1";
LambdaFunction foreign = function(owner, region, "$LATEST");
function(owner, region, "1");
function(owner, region, "2").setSnapStartApplyOn("PublishedVersions");
alias(owner, region, "live", "1", Map.of());
pool.put(region, "example", "live", 1, owner);
assertSnapStartConflict(assertThrows(AwsException.class,
() -> pool.validateAliasUpdate(foreign, "live", "2")));
put(1);
assertDoesNotThrow(() -> pool.validateAliasUpdate(version, "live", "2"));
}
private static void assertSnapStartConflict(AwsException error) {
assertEquals("ResourceConflictException", error.getErrorCode());
assertEquals(409, error.getHttpStatus());
assertEquals("The operation cannot be performed at this time. "
+ "Provisioned Concurrency is not supported for SnapStart enabled functions", error.getMessage());
}
@ParameterizedTest
@ValueSource(strings = {"example", "absent"})
void unpublishedVersionErrorsDependOnTheOperation(String name) {