* Restores the serverless service configuration to its original state. Specifically: * 1. Resets the IAM configuration. * 2. Resets all function configurations to their original handler, runtime, and environment variables. * * @async * @returns {Promise } A promise that resol
()
| 729 | * @returns {Promise<void>} A promise that resolves once all configurations have been successfully restored. |
| 730 | */ |
| 731 | async restore() { |
| 732 | logger.debug( |
| 733 | 'Restoring service configuration to its original state in memory', |
| 734 | ) |
| 735 | this.serverless.service.provider.iam = this.originalIamConfig |
| 736 | |
| 737 | this.serverless.service.getAllFunctions().forEach((functionName) => { |
| 738 | const functionConfig = this.serverless.service.getFunction(functionName) |
| 739 | |
| 740 | const originalFunctionConfig = this.originalFunctionConfigs[functionName] |
| 741 | |
| 742 | // If the function was not updated, we don't need to restore it |
| 743 | if (!originalFunctionConfig) { |
| 744 | return |
| 745 | } |
| 746 | |
| 747 | const { handler, runtime, environment } = originalFunctionConfig |
| 748 | |
| 749 | functionConfig.handler = handler |
| 750 | functionConfig.environment = environment |
| 751 | functionConfig.runtime = this.provider.getRuntime(runtime) |
| 752 | }) |
| 753 | } |
| 754 | |
| 755 | /** |
| 756 | * Clears service-level and per-function package artifacts in the in-memory configuration. |
no test coverage detected