File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -525,6 +525,7 @@ class Variables {
525525 }
526526
527527 getValueFromSelf ( variableString ) {
528+ const selfServiceRex = / s e l f : s e r v i c e \. / ;
528529 let variable = variableString ;
529530 // ###################################################################
530531 // ## KEEP SYNCHRONIZED WITH EQUIVALENT IN ~/lib/classes/Service.js ##
@@ -534,8 +535,9 @@ class Variables {
534535 // Account for these so that user's reference to their file populate properly
535536 if ( variable === 'self:service.name' ) {
536537 variable = 'self:service' ;
537- }
538- if ( variable === 'self:provider' ) {
538+ } else if ( variable . match ( selfServiceRex ) ) {
539+ variable = variable . replace ( selfServiceRex , 'self:serviceObject.' ) ;
540+ } else if ( variable === 'self:provider' ) {
539541 variable = 'self:provider.name' ;
540542 }
541543 const valueToPopulate = this . service ;
Original file line number Diff line number Diff line change @@ -1156,6 +1156,18 @@ module.exports = {
11561156 } ;
11571157 return serverless . variables . getValueFromSelf ( 'self:provider' ) . should . become ( 'aws' ) ;
11581158 } ) ;
1159+ it ( 'should redirect ${self:service.awsKmsKeyArn} to ${self:serviceObject.awsKmsKeyArn}' , ( ) => {
1160+ const keyArn = 'arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ;
1161+ serverless . variables . service = {
1162+ service : 'testService' ,
1163+ serviceObject : {
1164+ name : 'testService' ,
1165+ awsKmsKeyArn : keyArn ,
1166+ } ,
1167+ } ;
1168+ return serverless . variables . getValueFromSelf ( 'self:service.awsKmsKeyArn' )
1169+ . should . become ( keyArn ) ;
1170+ } ) ;
11591171 it ( 'should handle self-references to the root of the serverless.yml file' , ( ) => {
11601172 serverless . variables . service = {
11611173 service : 'testService' ,
You can’t perform that action at this time.
0 commit comments