Skip to content

Commit

Permalink
\serverless#8692: Add kmsKeyArn property to provider and
Browse files Browse the repository at this point in the history
`function[]` objects for single function deployment
  • Loading branch information
ifitzsimmons committed Dec 31, 2020
1 parent 715ba60 commit d38eb8b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
25 changes: 21 additions & 4 deletions lib/plugins/aws/deployFunction.js
Expand Up @@ -103,10 +103,27 @@ class AwsDeployFunction {
FunctionName: functionObj.name,
};

if ('awsKmsKeyArn' in functionObj && !_.isObject(functionObj.awsKmsKeyArn)) {
params.KMSKeyArn = functionObj.awsKmsKeyArn;
} else if (serviceObj && 'awsKmsKeyArn' in serviceObj && !_.isObject(serviceObj.awsKmsKeyArn)) {
params.KMSKeyArn = serviceObj.awsKmsKeyArn;
let kmsKeyArn = functionObj.kmsKeyArn || serviceObj.kmsKeyArn;
if (!kmsKeyArn && functionObject.awsKmsKeyArn) {
kmsKeyArn = functionObject.awsKmsKeyArn;

this.serverless._logDeprecation(
'FUNCTION_DEPRECATED_PROPERTY_AWS_KMS_KEY_ARN',
`Starting with next major version, awsKmsKeyArn function property will
\sbe replaced by kmsKeyArn.`
);
} else if (!kmsKeyArn && serviceObj.awsKmsKeyArn) {
kmsKeyArn = serviceObj.awsKmsKeyArn;

this.serverless._logDeprecation(
'SERVICE_DEPRECATED_PROPERTY_AWS_KMS_KEY_ARN',
`Starting with next major version, awsKmsKeyArn service property will\s
\sbe replaced by provider.kmsKeyArn.`
)
}

if (kmsKeyArn) {
params.KMSKeyArn = kmsKeyArn
}

if ('description' in functionObj && !_.isObject(functionObj.description)) {
Expand Down
5 changes: 5 additions & 0 deletions lib/plugins/aws/provider.js
Expand Up @@ -384,6 +384,10 @@ class AwsProvider {
],
},
},
awsKmsArn: {
type: 'string',
pattern: '^arn:aws:kms:*$',
},
awsLambdaEnvironment: {
type: 'object',
patternProperties: {
Expand Down Expand Up @@ -590,6 +594,7 @@ class AwsProvider {
},
additionalProperties: false,
},
awsKmsKeyArn: { $ref: '#/definitions/awsKmsArn' },
cfnRole: { $ref: '#/definitions/awsArn' },
cloudFront: {
type: 'object',
Expand Down

0 comments on commit d38eb8b

Please sign in to comment.