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

Config schema: Define AWS "httpApi" function event properties #8021

Closed
2 tasks done
medikoo opened this issue Jul 31, 2020 · 2 comments · Fixed by #8068
Closed
2 tasks done

Config schema: Define AWS "httpApi" function event properties #8021

medikoo opened this issue Jul 31, 2020 · 2 comments · Fixed by #8068

Comments

@medikoo
Copy link
Contributor

medikoo commented Jul 31, 2020

Use case description

It'll be nice to have httpApi event fully covered by schema validation

Proposed solution

  1. Define schema for following properties at provider level (that's part of Config schema: Define AWS "provider" properties #8022)
  • httpApi
  • logs.httpApi

Should be done directly in: lib/plugins/aws/provider/awsProvider.js:

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8016
serverless.configSchemaHandler.defineProvider('aws', {

  1. Define schema of all httpApi event properties

Should be done directly in: lib/plugins/aws/package/compile/events/httpApi/index.js:

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8021
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'httpApi', {
anyOf: [{ type: 'string' }, { type: 'object' }],
});

@fredericbarthelet
Copy link
Contributor

@medikoo I just realized I missed a particular scenario in my first PR : what happens if any of accepted string property within the configuration, both at provider and event level, is defined using cloudformation functions.

As an exemple, for httpApi provider configuration, the attribute id also accept an object with Fn::ImportValue key.

The use of CFN native function for string values is not httpApi specific. A reusable JSON schema ref would come in handy, WDYT ?

@medikoo
Copy link
Contributor Author

medikoo commented Aug 20, 2020

@medikoo I just realized I missed a particular scenario in my first PR

Yes, I've also noticed that :) Actually a lot of got exposed after #8091 went in (you didn't have it yet in your PR, so it was silent for you). As it went already to master, I fixed that quickly with #8099

As an exemple, for httpApi provider configuration, the attribute id also accept an object with Fn::ImportValue key.

I've fixed it here: #8102 (this unfortunately is not covered by tests, I just happened to remind my myself about that, hence addressed with follow up PR)

Now config errors are exposed as crashes with tests, so it's unlikely we repeat merging incomplete schema (but that still depends on how good is tests coverage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants