fix(pipes): restore a CloudFormation snapshot without re-validating it (#3218)

* fix(pipes): restore a CloudFormation snapshot without re-validating it

restorePipe went through the same source validation as UpdatePipe, so a
pipe whose persisted configuration predates a rule added since (a Kafka
source without TopicName, or a ParallelizationFactor outside 1..10 after
#3192) could not be put back after a failed stack update and the resource
ended up UPDATE_ROLLBACK_FAILED. Validation now runs on the UpdatePipe
path only; a restore writes the configuration that was already accepted.

Fixes #3209

* fix(pipes): validate an update against the pipe it mutates

UpdatePipe looked the pipe up once to validate the source configuration
and writePipeConfiguration looked it up again to mutate it, so a pipe
deleted and recreated between the two would be validated as the old pipe
and written as the new one. Validate inside writePipeConfiguration on
the single retrieved instance, skipped only on the restore path.
This commit is contained in:
BingEdward authored and GitHub committed 2026-09-07 22:40:16 -05:00
1 parent f7efb71467
commit d95ed9f8fe
2 files changed
+49 -7

No files matched your search

@@ -25,13 +25,15 @@ class PipesServiceTest {
private static final ObjectMapper MAPPER = new ObjectMapper();
private AccountAwareStorageBackend<Pipe> storage;
private PipesService pipesService;
@BeforeEach
void setUp() {
storage = AccountAwareStorageBackend.inMemory("000000000000");
StorageFactory storageFactory = Mockito.mock(StorageFactory.class);
when(storageFactory.create(Mockito.anyString(), Mockito.anyString(), Mockito.any()))
.thenReturn(AccountAwareStorageBackend.inMemory("000000000000"));
Mockito.doReturn(storage).when(storageFactory)
.create(Mockito.anyString(), Mockito.anyString(), Mockito.any());
RegionResolver regionResolver = new RegionResolver("us-east-1", "000000000000");
@@ -233,6 +235,38 @@ class PipesServiceTest {
assertEquals(PipeState.STOPPED, restored.getCurrentState());
}
/**
* A restore puts back a configuration that was accepted when it was written, so it is not run
* through the source validation again. A persisted pipe can predate a rule added since, and a
* CloudFormation rollback that re-validated its snapshot would fail on the very pipe it is
* putting back. The pipe is seeded straight into storage, as one written before the Kafka
* TopicName check existed would be.
*/
@Test
void restorePipeDoesNotRevalidateAnAlreadyAcceptedConfiguration() {
JsonNode legacyParameters = sourceParameters("""
{"SelfManagedKafkaParameters":{"BatchSize":10}}""");
Pipe legacy = new Pipe();
legacy.setName("legacy-pipe");
legacy.setArn("arn:aws:pipes:us-east-1:000000000000:pipe/legacy-pipe");
legacy.setSource("smk://broker:9092");
legacy.setTarget("arn:aws:sqs:us-east-1:000000000000:target");
legacy.setRoleArn("arn:aws:iam::000000000000:role/role");
legacy.setDesiredState(DesiredState.RUNNING);
legacy.setCurrentState(PipeState.RUNNING);
legacy.setSourceParameters(legacyParameters);
storage.put("us-east-1::legacy-pipe", legacy);
Pipe restored = pipesService.restorePipe("legacy-pipe",
"arn:aws:sqs:us-east-1:000000000000:target",
"arn:aws:iam::000000000000:role/role",
null, null, null, legacyParameters, null, null, "us-east-1");
assertEquals(legacyParameters, restored.getSourceParameters());
assertEquals(legacyParameters,
pipesService.describePipe("legacy-pipe", "us-east-1").getSourceParameters());
}
@Test
void deletePipe() {
pipesService.createPipe("del-pipe",