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

Incorrect configuration warning for apiKeys object #9080

Closed
lyndoh opened this issue Mar 5, 2021 · 3 comments · Fixed by #9489
Closed

Incorrect configuration warning for apiKeys object #9080

lyndoh opened this issue Mar 5, 2021 · 3 comments · Fixed by #9489

Comments

@lyndoh
Copy link
Contributor

lyndoh commented Mar 5, 2021

There appears to be a mismatch between the config validation and the implementation for aws api gateway apiKeys where multiple usage plans are allowed.
A configuraton warning like:

Configuration warning at 'provider.apiGateway.apiKeys[0].nolimit[0]': should be string

is displayed when an apiKey object is configured where the "multiple usage plan" format is used (see serverless.yml). However the CFT compiles with the configured values and deploys successfully as expected.
CFT will contain valid/expected output along the lines of:

"ApiGatewayApiKeyNolimit1": {
      "Type": "AWS::ApiGateway::ApiKey",
      "Properties": {
        "Enabled": true,
        "Description": "Key for unlimited API access",

Happy to PR a fix to the config validation schema.

serverless.yml
service: my-service

provider:
  name: aws
  runtime: nodejs14.x
  stage: blah
  region: ap-southeast-2
  profile: ${env:AWS_PROFILE}
  endpointType: REGIONAL
  lambdaHashingVersion: 20201221 # will become default in serverless 3.0
  apiGateway:
    shouldStartNameWithService: true
    apiKeys:
      - nolimit:
          - description: Key for unlimited API access
    usagePlan:
      - nolimit:
sls package output
Serverless: Configuration warning at 'provider.apiGateway.apiKeys[0].nolimit[0]': should be string
Serverless:  
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:  
Serverless: Packaging service...
Serverless: Excluding development dependencies...

Installed version

Framework Core: 2.28.7 (local)
Plugin: 4.4.3
SDK: 2.3.2
Components: 3.7.2
@pgrzesik
Copy link
Contributor

pgrzesik commented Mar 5, 2021

Thanks @lyndoh for reporting. I believe that we indeed have mismatching schema vs what is actually expected and supported when it comes to apiKeys for apiGateway. We'd be more than happy to accept a PR for this one 🙇

@lyndoh
Copy link
Contributor Author

lyndoh commented May 17, 2021

Hi @pgrzesik

I'm finally getting around to a PR for this, but unsure where to add tests for the schema. Is adding new cases to test/unit/lib/configSchema.test.js the correct place?

Thanks

@pgrzesik
Copy link
Contributor

Hey @lyndoh 👋

We usually don't test schema itself, the better idea here would be to implement tests that the desired configuration is supported with runServerless-based tests, which fails on invalid schema definition. In this case it would require adding tests here: https://github.com/serverless/serverless/blob/master/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/apiKeys.test.js

One note, the new tests should be written using runServerless approach as outlined in https://github.com/serverless/serverless/blob/master/test/README.md

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.

3 participants