Hello, I would have some questions about serverless.ts.
I the how would I reference a value from another field?
How would I reference the value of an argument passed in the CLI?
Thanks for your help !
1 Like
Hi @BjMrq,
A few responses based on my usage so far:
Q: I the how would I reference a value from another field?
A: You can use the same process actually and it’s translated later at runtime. So you can obtain a custom variable like this (somewhat silly example):
.
.
.
custom:
doMagicName:
prod: "doMagic - enabled"
dev: "doMagic - disabled"
.
.
.
doMagic: {
handler: 'handler.doMagic',
events: [
{
sns: {
topicName: "doMagic-${opt:stage}",
displayName: "doMagic - ${self:custom.doMagicName.${opt:stage}",
},
},
],
.
.
.
Q: How would I reference the value of an argument passed in the CLI?
A: You can use the same process as above, just use the ${opt:some_option}
syntax you would use in your serverless.yml
file.
environment:
stage: "${opt:stage}"
2 Likes
Thanks! Will try it, have a good day
1 Like