Skip to content

Commit

Permalink
fix: deploy function to update runtime (#12454)
Browse files Browse the repository at this point in the history
  • Loading branch information
eahefnawy committed Apr 29, 2024
1 parent b5953db commit 7c84124
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/plugins/aws/deploy-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import ServerlessError from '../../serverless-error.js';
class AwsDeployFunction {
constructor(serverless, options, pluginUtils) {
this.serverless = serverless;
this.logger = pluginUtils.log
this.loggerStyle = pluginUtils.style
this.progress = pluginUtils.progress
this.logger = pluginUtils.log;
this.loggerStyle = pluginUtils.style;
this.progress = pluginUtils.progress;
this.options = options || {};
this.packagePath =
this.options.package ||
Expand All @@ -31,17 +31,19 @@ class AwsDeployFunction {
this.logger.notice(
`Deploying function "${this.options.function}" to stage "${this.serverless
.getProvider('aws')
.getStage()}" ${this.loggerStyle.aside(`(${this.serverless.getProvider('aws').getRegion()})`)}`
.getStage()}" ${this.loggerStyle.aside(
`(${this.serverless.getProvider('aws').getRegion()})`
)}`
);
},
'before:deploy:function:initialize': () =>
this.progress.notice('Validating', { isMainEvent: true }),
'deploy:function:initialize': async () => {
this.logger.debug('validating...');
await this.validate();
this.logger.debug('checking if function exists...')
this.logger.debug('checking if function exists...');
await this.checkIfFunctionExists();
this.logger.debug('checking if function changed...')
this.logger.debug('checking if function changed...');
this.checkIfFunctionChangesBetweenImageAndHandler();
},

Expand All @@ -54,7 +56,7 @@ class AwsDeployFunction {
this.progress.notice('Packaging', { isMainEvent: true }),
'deploy:function:deploy': async () => {
if (!this.options['update-config']) {
this.logger.debug('deploying function code...')
this.logger.debug('deploying function code...');
await this.deployFunction();
}
await this.updateFunctionConfiguration();
Expand Down Expand Up @@ -182,7 +184,7 @@ class AwsDeployFunction {
}

async callUpdateFunctionConfiguration(params) {
this.logger.debug('deploying function configuration changes...')
this.logger.debug('deploying function configuration changes...');

const startTime = Date.now();

Expand Down Expand Up @@ -268,6 +270,12 @@ class AwsDeployFunction {
delete params.Timeout;
}

const runtime = this.provider.getRuntime(functionObj.runtime);

if (runtime !== remoteFunctionConfiguration.Runtime) {
params.Runtime = runtime;
}

// Check if we have remotely managed layers and add them to the update call
// if they exist in the remote function configuration.
const isConsoleSdkLayerArn = RegExp.prototype.test.bind(
Expand Down

0 comments on commit 7c84124

Please sign in to comment.