Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
This repository was archived by the owner on May 1, 2020. It is now read-only.

Support for nested state reference #13

@serverlessguru

Description

@serverlessguru

Currently it appears to not be possible to reference a nested state object inside the serverless.yml file.

serverless.yml:

cognitoUserPool:
  component: '@serverless/aws-cognito'
  inputs:
    region: us-east-1
    authTemplate: COGNITO_USER_POOL

myAppSyncApi:
  component: "@serverless/aws-app-sync"
  inputs:
    name: appApi

    # Amazon Cognito Authentication
    authenticationType: AMAZON_COGNITO_USER_POOLS
    userPoolConfig:
      awsRegion: us-east-1
      defaultAction: ALLOW
      userPoolId: ${cognitoUserPool.app.poolId}

state file (Template.cognitoUserPool.json):

{
  "app": {
    "poolId": "us-east-1sxxxxxxx",
    "poolArn": "xxxxxxxxxxxxx",
    "clientId": "xxxxxxxxxxxxxxx"
  },
  "region": "us-east-1"
}

Error:

error:
  Error: invalid reference ${cognitoUserPool.app.poolId}
    at Object.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:59:17)
    at walker (/usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:190:22)
    at /usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:208:29
    at Array.forEach (<anonymous>)
    at forEach (/usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:298:31)
    at walker (/usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:203:13)
    at /usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:208:29
    at Array.forEach (<anonymous>)
    at forEach (/usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:298:31)
    at walker (/usr/local/lib/node_modules/serverless/node_modules/traverse/index.js:203:13)

  4s › usersLambda › Error: invalid reference ${cognitoUserPool.app.poolId}

Why would you want to do this?
When creating Serverless Components, you need to save state (e.g. this.save()) and it's much easier to logically group things together (by a key) than to have it all be flat inside the Template.cognitoUserPool.json object.

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions