Skip to content

Commit

Permalink
fix(Config Schema): Recognize deployment valid env variables format
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 30, 2020
1 parent 8c4d972 commit eb5e548
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
34 changes: 16 additions & 18 deletions lib/plugins/aws/invokeLocal/index.js
Expand Up @@ -183,26 +183,24 @@ class AwsInvokeLocal {

const configuredEnvVars = this.getConfiguredEnvVars();

const promises = Object.entries(configuredEnvVars).map(([name, value]) => {
let resolver;
if (value['Fn::ImportValue']) {
resolver = resolveCfImportValue(this.provider, value['Fn::ImportValue']);
} else if (value.Ref) {
resolver = resolveCfRefValue(this.provider, value.Ref);
} else {
resolver = BbPromise.resolve(value);
}

return resolver.then(
resolvedValue => {
configuredEnvVars[name] = resolvedValue;
},
error => {
throw new this.serverless.classes.Error(
`Could not resolve ${name} environment variable. ${error.message}`
const promises = Object.entries(configuredEnvVars).map(async ([name, value]) => {
if (!_.isObject(value)) return;
try {
if (value['Fn::ImportValue']) {
configuredEnvVars[name] = await resolveCfImportValue(
this.provider,
value['Fn::ImportValue']
);
} else if (value.Ref) {
configuredEnvVars[name] = await resolveCfRefValue(this.provider, value.Ref);
} else {
throw new Error(`Unsupported format: ${inspect(value)}`);
}
);
} catch (error) {
throw new this.serverless.classes.Error(
`Could not resolve "${name}" environment variable: ${error.message}`
);
}
});

return BbPromise.all(promises).then(() => {
Expand Down
8 changes: 1 addition & 7 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -285,13 +285,7 @@ class AwsProvider {
awsLambdaEnvironment: {
type: 'object',
patternProperties: {
'^[A-Za-z_][a-zA-Z0-9_]*$': {
anyOf: [
{ type: 'string' },
{ $ref: '#/definitions/awsCfImport' },
{ $ref: '#/definitions/awsCfRef' },
],
},
'^[A-Za-z_][a-zA-Z0-9_]*$': { $ref: '#/definitions/awsCfInstruction' },
},
additionalProperties: false,
},
Expand Down

0 comments on commit eb5e548

Please sign in to comment.