Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

varibales in tables names in serverless.yml #17

Closed
SET001 opened this issue Sep 7, 2018 · 8 comments
Closed

varibales in tables names in serverless.yml #17

SET001 opened this issue Sep 7, 2018 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@SET001
Copy link
Contributor

SET001 commented Sep 7, 2018

It seems like currenlty emulator does not revognize variables in table names in serverless.yml file.

having such a declaration in yml:
TableName: ens-webhooks-${self:provider.stage}
I'm getting error this error when starting emulator:

{ ValidationException: Invalid table/index name. Table/index names must be between 3 and 255 characters long, and may contain only the characters a-z, A-Z, 0-9, '_', '-', and '.'
it's sad that the error message does not contain actual table name which occures error.

After digging a bit I found that error comes from asw-sdk and the params passed there contain, among all others, such thing:

params: { TableName: 'ens-webhooks-${self:provider.stage}',

am I doing something wrong or emulator indeed does not support variables in yml?

@cbaron
Copy link
Contributor

cbaron commented Sep 7, 2018

@SET001 -- You're correct. At the moment we do not support variables. This should not take long to implement and will put it on my task queue. In the meantime, you are welcome to put up a PR.

@cbaron cbaron added the bug Something isn't working label Sep 7, 2018
@SET001
Copy link
Contributor Author

SET001 commented Sep 8, 2018

@cbaron I have some free time on this weekends so I difinelty can try to prepare some PR. Can you give me a short help on where to begin with and how you see realisation?

@SET001
Copy link
Contributor Author

SET001 commented Sep 8, 2018

from what I see in code, here we have loadServerlessConfig that can be used to load and parse yml file and seems like it resolves variables correctly. Can it be used in server.js:createSchema?

@lightsofapollo
Copy link
Contributor

@SET001 I added a test case and fixed it for this particular issue. This should be fixed in 0.7.3

@SET001
Copy link
Contributor Author

SET001 commented Sep 10, 2018

than you, it is fixed now )

@SET001
Copy link
Contributor Author

SET001 commented Sep 10, 2018

I thisnk following also related to this issue. The problem is that you can't use Rel syntax in yml files. The following defenition

    dataSources:
      - type: AMAZON_DYNAMODB
        name: Subscriber
        description: 'Subscribers table'
        config:
          tableName: {Ref: EnsSubscribersDDBTable}

result it such an error:

✖ error Query.getAllSubscribers failed
✖ error InvalidParameterType: Expected params.TableName to be a string

@lightsofapollo
Copy link
Contributor

@SET001 This one is harder I don't think we can support cloud formation template syntax at this time. Can you assign the name to a serverless variable and use it in both places?

@lightsofapollo
Copy link
Contributor

If needed pleas open a new issue to discuss supporting cloud formation syntax. I don't think we can support it at this time but if it's a serious blocker we can see what we can do.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants