Serverless.ts : How to use !Sub or Fn::Sub when resolving pseudo parameters ${AWS:AccountId} in typescript?

hi there,
i can’t get my head around on how to reference the new built in pseudo parameters support in a serverless.ts file so that the ${AWS:AccountId} gets substituted correctly within a serverless.ts (typescript) config file.

Thanks for any help and suggestions:

Hi @m.schubert I was also looking for a solution to this and I came across your question. I was able to resolve it and I see that the issue with yours is that you are wrapping the line that contains ‘Fn::Sub’ in single quotes. Here’s an example below from my code:

Resource: { ‘Fn::Sub’: ‘arn:aws:es:${self:provider.region}:${AWS::AccountId}:domain/images-search-${self:provider.stage}/*’ }

As you can see the Object that contains ‘Fn:Sub’ is not wrapped in quotes. The link to my full serverless.ts file is udacity-cloud-developer-serverless-lesson3/serverless.ts at main · tobennanwokike/udacity-cloud-developer-serverless-lesson3 · GitHub

I hope this helps.

Happy Coding!

1 Like