Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize deployment valid env variables format #8307

Merged
merged 1 commit into from Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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