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

API Gateway with usage plans and api key groups are not config errors #9529

Closed
dazza-codes opened this issue May 29, 2021 · 3 comments
Closed
Labels

Comments

@dazza-codes
Copy link

The example for API keys in https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/
does not provide any nested values for groups of API users. i.e.

    apiKeys: # List of API keys to be used by your service API Gateway REST API
      - myFirstKey
        value: myFirstKeyValue
        description: myFirstKeyDescription
        customerId: myFirstKeyCustomerId
      - ${opt:stage}-myFirstKey
      - ${env:MY_API_KEY} # you can hide it in a serverless variable

In the example below, the API users are grouped into 2 groups that have different usage plans.

Why are the groups of API users below raising configuration errors like the following?

$ sls info
Serverless: Configuration warning:
Serverless:   at 'provider.apiGateway.apiKeys[0].paid[0]': should be string
Serverless:   at 'provider.apiGateway.apiKeys[1].free[0]': should be string
Serverless:   at 'provider.apiGateway.apiKeys[1].free[1]': should be string
Serverless:  
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:  

Sample of API users and usage plans for groups of users:

provider:

  apiGateway:

    apiKeys:
      - paid:
        - name: api-userA-dev
          value: secret-key-a
          customerId: userA
      - free:
        - name: api-userB-dev
          value: secret-key-b
          customerId: userB
        - name: api-userC-dev
          value: secret-key-c
          customerId: userC

    usagePlan:
      - paid:
          quota:
            limit: 1000000
            offset: 0
            period: DAY
          throttle:
            burstLimit: 1000
            rateLimit: 500
      - free:
          quota:
            limit: 5000
            offset: 0
            period: DAY
          throttle:
            burstLimit: 50
            rateLimit: 10

Installed version

Framework Core: 2.41.2
Plugin: 5.1.0
SDK: 4.2.2
Components: 3.9.2
@pgrzesik
Copy link
Contributor

Hello @dazza-codes - could you please upgrade to the latest version of the Framework? I believe that issue has been addressed as a part of #9489

@dazza-codes
Copy link
Author

dazza-codes commented May 30, 2021

$ sls --version
Framework Core: 2.43.1
Plugin: 5.1.4
SDK: 4.2.2
Components: 3.10.1

The API keys issue is no longer reported as a config error in this update. All that remains for a v2 updated serverless.yml file are a couple deprecation warnings

Serverless: Deprecation warning: Variables resolver reports following resolution errors:
              - Cannot resolve variable at "custom.dynamicOpts": Cannot resolve "dynamic" out of "serverless-helpers.js": Resolved a JS function not confirmed to work with a new parser, falling back to old resolver
            From a next major this will be communicated with a thrown error.
            Set "variablesResolutionMode: 20210326" in your service config, to adapt to new behavior now
            More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_VARIABLES_RESOLVER
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2

These are not related to this issue. I'm completely confused by the serverless-helpers.js solution and discuss that in

Thanks for the help in resolving this API keys issue. This issue could be closed.

@pgrzesik
Copy link
Contributor

Hello @dazza-codes - thanks for upgrading and happy to hear that this issue has been resolved. As for new variables resolver - did you have a chance to look at https://www.serverless.com/framework/docs/providers/aws/guide/variables/#exporting-a-function ? Is the serverless-helpers.js compatible with that approach?

I'm going to close this issue, thanks 🙇

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

No branches or pull requests

2 participants