question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't concatenate in serverless.yml

See original GitHub issue

I’m currently migrating from the plugin to the component.

In my existing serverless.yml I am able to do this sort of thing:

domainName: ${env:STAGE}-front-end.mydomain.com

But in the component if I do this

ph-front-end:
  component: '@sls-next/serverless-component@1.16.0-alpha.1'
  inputs:
    domain:
      - ${env.STAGE}-front-end
      - mydomain.com

Then it doesn’t seem to concatenate.

Also with the lambda names:

name:
  defaultLambda: ${env.STAGE}-front-end
  apiLambda: ${env.STAGE}-front-end-api

In that case I just get the STAGE variable without the -front-end added on.

If the syntax works in the old serverless.yml I’m surprised it doesn’t work in the new serverless.yml.

Am I doing something wrong? I don’t want to have to send ${SUBDOMAIN}, ${LAMBDA_NAME}, ${API_LAMBDA_NAME}, etc. when they’re all just derivations off of ${STAGE}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mattdellcommented, Aug 25, 2020

I have no explanation for this, but the trick is to set stage as a veriable in the component and then reference that. Referencing the environment variable directly seems to just overwrite everything.

Working configuration

stage: ${env.STAGE}
my-app:
  component: '@sls-next/serverless-component@1.16.0-alpha.1'
  inputs:
    domain:
      - '${stage}-front-end'
      - mydomain.com
0reactions
mattdellcommented, Aug 25, 2020

That doesn’t work either. So frustrating.

domain:
  - '${env.STAGE}-front-end'
  - mydomain.com

Then running

env STAGE=dev npx serverless

I get a domain of https://dev.mydomain.com rather than what I’d expect to be https://dev-front-end.mydomain.com

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to concatenate env variable to string in YAML file
I have a serverless.yaml file and I ...
Read more >
Variables - Serverless Framework
Variables. Variables allow users to dynamically replace config values in serverless.yml config. They are especially useful when providing secrets for your ...
Read more >
AWS Lambda Guide - Serverless.yml Reference
Here is a list of all available properties in serverless.yml when the provider is set to aws . ... Fn::Join: ... Cannot be...
Read more >
Introducing multi-service deployments via Serverless ...
We are excited to announce Serverless Framework Compose: a new feature enabling you to deploy multiple services in one command, in parallel, ...
Read more >
AWS Lambda Functions - Serverless Framework
... service can be found in serverless.yml under the functions property. ... Fn::Join: ... buildArgs , cacheFrom , and platform cannot be defined....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found