diff --git a/lib/classes/Variables.js b/lib/classes/Variables.js index c65866f3b..9a93c6a2d 100644 --- a/lib/classes/Variables.js +++ b/lib/classes/Variables.js @@ -102,6 +102,10 @@ class Variables { const requiredConfigs = [ _.assign({ name: 'region' }, provider.getRegionSourceValue()), _.assign({ name: 'stage' }, provider.getStageSourceValue()), + _.assign({ name: 'profile' }, { + value: this.service.provider.profile, + path: 'serverless.service.provider.profile', + }), ]; return this.disableDepedentServices(() => { const prepopulations = requiredConfigs.map(config => diff --git a/lib/classes/Variables.test.js b/lib/classes/Variables.test.js index f8af35f59..23e5fdf84 100644 --- a/lib/classes/Variables.test.js +++ b/lib/classes/Variables.test.js @@ -147,11 +147,12 @@ describe('Variables', () => { const prepopulatedProperties = [ { name: 'region', getter: (provider) => provider.getRegion() }, { name: 'stage', getter: (provider) => provider.getStage() }, + { name: 'profile', getter: (provider) => provider.getProfile() }, ]; describe('basic population tests', () => { prepopulatedProperties.forEach((property) => { it(`should populate variables in ${property.name} values`, () => { - awsProvider.options[property.name] = '${self:foobar, "default"}'; + awsProvider.serverless.service.provider[property.name] = '${self:foobar, "default"}'; return serverless.variables.populateService().should.be.fulfilled .then(() => expect(property.getter(awsProvider)).to.be.eql('default')); }); @@ -167,7 +168,7 @@ describe('Variables', () => { prepopulatedProperties.forEach(property => { dependentConfigs.forEach(config => { it(`should reject ${config.name} variables in ${property.name} values`, () => { - awsProvider.options[property.name] = config.value; + awsProvider.serverless.service.provider[property.name] = config.value; return serverless.variables.populateService() .should.be.rejectedWith('Variable dependency failure'); }); @@ -175,7 +176,7 @@ describe('Variables', () => { serverless.variables.service.custom = { settings: config.value, }; - awsProvider.options.region = '${self:custom.settings.region}'; + awsProvider.serverless.service.provider.region = '${self:custom.settings.region}'; return serverless.variables.populateService() .should.be.rejectedWith('Variable dependency failure'); }); @@ -196,8 +197,8 @@ describe('Variables', () => { { name: 'getValueFromS3', original: serverless.variables.getValueFromS3 }, { name: 'getValueFromSsm', original: serverless.variables.getValueFromSsm }, ]; - awsProvider.options.region = combination.region; - awsProvider.options.state = combination.state; + awsProvider.serverless.service.provider.region = combination.region; + awsProvider.serverless.service.provider.state = combination.state; return serverless.variables.populateService().should.be.fulfilled .then(() => { dependentMethods.forEach((method) => { diff --git a/lib/plugins/aws/provider/awsProvider.js b/lib/plugins/aws/provider/awsProvider.js index a5ff03a02..fec6d92e3 100644 --- a/lib/plugins/aws/provider/awsProvider.js +++ b/lib/plugins/aws/provider/awsProvider.js @@ -410,6 +410,7 @@ class AwsProvider { getProfileSourceValue() { const values = this.getValues(this, [ + ['options', 'aws-profile'], ['options', 'profile'], ['serverless', 'config', 'profile'], ['serverless', 'service', 'provider', 'profile'],