Rich
Rich

Reputation: 5731

Accessing a property of an alias in YAML

I have the below code:

authenticationMethod: &authentication-method
  dev: 
    authenticationType: API_KEY
    additionalAuthenticationProviders:
      - authenticationType: OPENID_CONNECT
        openIdConnectConfig:
          issuer: https://tapendium.au.auth0.com
  uat:
    authenticationType: API_KEY
    additionalAuthenticationProviders:
      - authenticationType: OPENID_CONNECT
        openIdConnectConfig:
          issuer: https://tapendium.au.auth0.com

name: ${self:service}-${self:provider.stage}
schema: merged-schema.graphql
<<: *authentication-method.uat

How do I access the uat key as in *authentication-method.uat. The last line results in the error:

unidentified alias "authentication-method.uat"`

Upvotes: 1

Views: 373

Answers (1)

flyx
flyx

Reputation: 39688

You need to give the property an own alias, e.g.

authenticationMethod: &authentication-method
  dev: 
    authenticationType: API_KEY
    additionalAuthenticationProviders:
      - authenticationType: OPENID_CONNECT
        openIdConnectConfig:
          issuer: https://tapendium.au.auth0.com
  uat: &u
    authenticationType: API_KEY
    additionalAuthenticationProviders:
      - authenticationType: OPENID_CONNECT
        openIdConnectConfig:
          issuer: https://tapendium.au.auth0.com

name: ${self:service}-${self:provider.stage}
schema: merged-schema.graphql
<<: *u

YAML aliases are always a simple reference to a node, they are not some kind of query language.

Upvotes: 1

Related Questions