|
22 | 22 | )
|
23 | 23 | from localstack.services.cloudformation.resource_provider import (
|
24 | 24 | Credentials,
|
| 25 | + OperationStatus, |
25 | 26 | ResourceProviderExecutor,
|
26 | 27 | ResourceProviderPayload,
|
27 | 28 | get_resource_type,
|
@@ -1358,13 +1359,31 @@ def apply_change(self, change: ChangeConfig, stack: Stack) -> None:
|
1358 | 1359 |
|
1359 | 1360 | progress_event = executor.deploy_loop(resource_provider_payload) # noqa
|
1360 | 1361 |
|
| 1362 | + # TODO: clean up the surrounding loop (do_apply_changes_in_loop) so that the responsibilities are clearer |
| 1363 | + stack_action = get_action_name_for_resource_change(action) |
| 1364 | + match progress_event.status: |
| 1365 | + case OperationStatus.FAILED: |
| 1366 | + stack.set_resource_status(resource_id, f"{stack_action}_FAILED") |
| 1367 | + # TODO: remove exception raising here? |
| 1368 | + # TODO: fix request token |
| 1369 | + raise Exception( |
| 1370 | + f'Resource handler returned message: "{progress_event.message}" (RequestToken: 10c10335-276a-33d3-5c07-018b684c3d26, HandlerErrorCode: InvalidRequest){progress_event.error_code}' |
| 1371 | + ) |
| 1372 | + case OperationStatus.SUCCESS: |
| 1373 | + stack.set_resource_status(resource_id, f"{stack_action}_COMPLETE") |
| 1374 | + case OperationStatus.PENDING: |
| 1375 | + # this isn't really a state we use at the moment |
| 1376 | + raise Exception( |
| 1377 | + f"Usage of currently unsupported operation status detected: {OperationStatus.PENDING}" |
| 1378 | + ) |
| 1379 | + case OperationStatus.IN_PROGRESS: |
| 1380 | + raise Exception("Resource deployment loop should not finish in this state") |
| 1381 | + case unknown_status: |
| 1382 | + raise Exception(f"Unknown operation status: {unknown_status}") |
| 1383 | + |
1361 | 1384 | # TODO: this is probably already done in executor, try removing this
|
1362 | 1385 | resource["Properties"] = progress_event.resource_model
|
1363 | 1386 |
|
1364 |
| - # update resource status and physical resource id |
1365 |
| - stack_action = get_action_name_for_resource_change(action) |
1366 |
| - stack.set_resource_status(resource_id, f"{stack_action}_COMPLETE") |
1367 |
| - |
1368 | 1387 | def create_resource_provider_executor(self) -> ResourceProviderExecutor:
|
1369 | 1388 | return ResourceProviderExecutor(
|
1370 | 1389 | stack_name=self.stack.stack_name,
|
|
0 commit comments