How can I reference the ARN of a resource in a serverless.ts file? Details below…
I created a new Serverless project with the command: serverless create --template aws-nodejs-typescript
. I noticed that I am supplied with a serverless.ts
file now rather than a serverless.yml
file.
In the old serverless.yml
file I can get a resource’s ARN by using the following code:
custom:
AuctionsTable:
arn: !GetAtt AuctionsTable.Arn
I can reference that code elsewhere in the serverless.yml
with the following code:
Resource:
- ${self:custom.AuctionsTable.arn}
When I use the sls print
command, that code becomes CF code that looks like this:
Resource:
- 'Fn::GetAtt':
- AuctionsTable
- Arn
With the serverless.ts
file, that same code does not become the same CF code. The following code:
custom: {
auctionsTable: {
arn: "!GetAtt AuctionsTable.Arn"
}
Becomes the following after sls print
:
Resource:
- '!GetAtt AuctionsTable.Arn'
Which produces the following error when trying to deploy:
Resource !GetAtt AuctionsTable.Arn must be in ARN format or "*".
It seems like Serverless framework isn’t converting:
!GetAtt AuctionsTable.Arn
to:
Resource:
- 'Fn::GetAtt':
- AuctionsTable
- Arn
Any ideas on how to workaround this? Or am I taking the wrong approach?