From 1c927bc530890be93698043a5a0a9a1ac692f213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barthelet?= Date: Wed, 23 Sep 2020 13:53:30 +0200 Subject: [PATCH] Show depreciation warning unconditionnally --- lib/configSchema.js | 2 +- .../aws/package/compile/functions/index.js | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/configSchema.js b/lib/configSchema.js index b823b3513c2..f035a16f011 100644 --- a/lib/configSchema.js +++ b/lib/configSchema.js @@ -125,7 +125,7 @@ const schema = { additionalProperties: false, required: ['provider', 'service'], definitions: { - // TODO: awsKmsArn definition to be moved to lib/plugins/aws/provider/awsProvider.js once service.awsKmsKeyArn removed with v2.0.0, see https://github.com/serverless/serverless/issues/8261 + // TODO: awsKmsArn definition to be moved to lib/plugins/aws/provider/awsProvider.js once service.awsKmsKeyArn removed with v3.0.0, see https://github.com/serverless/serverless/issues/8261 // TODO: awsKmsArn to include #/definitions/awsCfFunction instead of type: object as one of the possible definition, see https://github.com/serverless/serverless/issues/8261 awsKmsArn: { anyOf: [{ type: 'object' }, { type: 'string', pattern: '^arn:aws[a-z-]*:kms' }], diff --git a/lib/plugins/aws/package/compile/functions/index.js b/lib/plugins/aws/package/compile/functions/index.js index 54b81f7700b..a834ca8cb7d 100644 --- a/lib/plugins/aws/package/compile/functions/index.js +++ b/lib/plugins/aws/package/compile/functions/index.js @@ -212,21 +212,26 @@ class AwsCompileFunctions { let kmsKeyArn; const serviceObj = this.serverless.service.serviceObject; - if (functionObject.kmsKeyArn || this.serverless.service.provider.kmsKeyArn) { - kmsKeyArn = functionObject.kmsKeyArn || this.serverless.service.provider.kmsKeyArn; - } else if (functionObject.awsKmsKeyArn) { - this.serverless._logDeprecation( - 'FUNCTION_DEPRECATED_PROPERTY_AWS_KMS_KEY_ARN', - 'Starting with next major version, awsKmsKeyArn function property will be replaced by kmsKeyArn.' - ); - kmsKeyArn = functionObject.awsKmsKeyArn; - } else if (serviceObj && serviceObj.awsKmsKeyArn) { + if (serviceObj && serviceObj.awsKmsKeyArn) { this.serverless._logDeprecation( 'SERVICE_DEPRECATED_PROPERTY_AWS_KMS_KEY_ARN', - 'Starting with next major version, awsKmsKeyArn service property will be replaced by provider.kmsKeyArn.' + 'Starting with next major version, awsKmsKeyArn service property will be replaced by provider.kmsKeyArn' ); kmsKeyArn = serviceObj.awsKmsKeyArn; } + if (this.serverless.service.provider.kmsKeyArn) { + kmsKeyArn = this.serverless.service.provider.kmsKeyArn; + } + if (functionObject.awsKmsKeyArn) { + this.serverless._logDeprecation( + 'FUNCTION_DEPRECATED_PROPERTY_AWS_KMS_KEY_ARN', + 'Starting with next major version, awsKmsKeyArn function property will be replaced by kmsKeyArn' + ); + kmsKeyArn = functionObject.awsKmsKeyArn; + } + if (functionObject.kmsKeyArn) { + kmsKeyArn = functionObject.kmsKeyArn; + } if (kmsKeyArn) { if (typeof kmsKeyArn === 'string') {