Skip to content

self should allow top-level references #3207

Closed

Description

@erikerikson

This is a Feature Proposal

Description

${self:} should be a valid value

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.

In order to define a value in one serverless.yml that can be used in another serverless.yml (to avoid copy-paste and synchronization problems), I must define the variable in a way that can render to the same concrete string from the context of multiple projects. To do this, both projects must define a custom.uniquePropery that references the top-level of the referred-to-project.

An example of this pattern is here:
https://github.com/Nordstrom/hello-retail/pull/26/files

In retail-stream/serverless.yml many custom.export* values are defined that I want to use in both products/lambda/serverless.yml and product-catalog/serverless.yml without copy-pasting the value.

This is possible since both contain:

  retailStream: ${file([../]../retail-stream/serverless.yml)}

And retail-stream/serverless.yml contains:

custom:
  stage: ${opt:stage, self:provider.stage, self:custom.private.stage}
  private: ${file(../private.yml)}
  helloRetail: ${file(../helloRetail.yml)}
  retailStreamVersion: 1 # The version of this service to depend upon
  retailStream: ${self:} # externally, use `${file(~/retail-stream/serverless.yml)}`, replacing the `~` therein with the appropriate relative reference [e.g. '..' or '../..']
  exportRetailStreamArn: ${self:custom.retailStream.service}:${self:custom.stage}:RetailStreamArn:${self:custom.retailStreamVersion}

Because of this pattern, the custom.export* values render to equivalent values in all projects.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions