Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deploy function to update runtime #12454

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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