Skip to content

Commit

Permalink
Use awsKmsArn definition everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbarthelet committed Sep 20, 2020
1 parent acb0495 commit 28bc5fa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/classes/ConfigSchemaHandler/index.js
Expand Up @@ -28,7 +28,8 @@ class ConfigSchemaHandler {
this.serverless = serverless;
this.schema = _.cloneDeep(schema);

deepFreeze(this.schema.properties.service);
// TODO: Switch back to deepFreeze(this.schema.properties.service) once awsKmsKeyArn property is removed, see https://github.com/serverless/serverless/issues/8261
Object.freeze(this.schema.properties.service.name);
deepFreeze(this.schema.properties.plugins);
deepFreeze(this.schema.properties.package);
Object.freeze(this.schema.properties.layers);
Expand Down
8 changes: 5 additions & 3 deletions lib/configSchema.js
Expand Up @@ -9,7 +9,7 @@ const schema = {
type: 'object',
properties: {
name: { pattern: '^[a-zA-Z][0-9a-zA-Z-]+$' },
awsKmsKeyArn: { pattern: '^arn:(aws[a-zA-Z-]*)?:kms:[a-z0-9-]+-\\d+:\\d{12}:[^\\s]+$' },
awsKmsKeyArn: { $ref: '#/definitions/awsKmsArnString' },
},
additionalProperties: false,
},
Expand Down Expand Up @@ -125,8 +125,10 @@ const schema = {
additionalProperties: false,
required: ['provider', 'service'],
definitions: {
awsKmsArn: {
oneOf: [{ $ref: '#/definitions/awsKmsArnString' }, { $ref: '#/definitions/awsCfFunction' }],
// TODO: awsKmsArnString definition to be moved to lib/plugins/aws/provider/awsProvider.js once service.awsKmsKeyArn moved to provider.awsKmsKeyArn, see https://github.com/serverless/serverless/issues/8261
awsKmsArnString: {
type: 'string',
pattern: '^arn:aws[a-z-]*:kms',
},
errorCode: {
type: 'string',
Expand Down
3 changes: 1 addition & 2 deletions lib/configSchema.test.js
Expand Up @@ -21,8 +21,7 @@ describe('#configSchema', () => {
},
{
isValid: false,
errorMessage:
'should match pattern "^arn:(aws[a-zA-Z-]*)?:kms:[a-z0-9-]+-\\d+:\\d{12}:[^\\s]+$',
errorMessage: 'should match pattern "^arn:aws[a-z-]*:kms',
description: 'service awsKmsKeyArn',
mutation: {
service: {
Expand Down
11 changes: 6 additions & 5 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -222,10 +222,6 @@ class AwsProvider {
required: ['Fn::Sub'],
additionalProperties: false,
},
awsKmsArnString: {
type: 'string',
pattern: '^arn:aws[a-z-]*:kms',
},
awsLambdaLayers: {
type: 'array',
items: { $ref: '#/definitions/awsArn' },
Expand Down Expand Up @@ -440,7 +436,12 @@ class AwsProvider {
},
function: {
properties: {
awsKmsKeyArn: { $ref: '#/definitions/awsKmsArn' },
awsKmsKeyArn: {
oneOf: [
{ $ref: '#/definitions/awsKmsArnString' },
{ $ref: '#/definitions/awsCfFunction' },
],
},
condition: {},
dependsOn: {},
description: { type: 'string', maxLength: 256 },
Expand Down

0 comments on commit 28bc5fa

Please sign in to comment.