Need some help with my aws configuration.
I have multiple services with its own serverless.yml
but i do have another serverless.yml at root, which contains some services (for reasons) and a resources.serverless.yml
// Here's the folder struct
- services
- A
- serverless.yml
- B
- C
- serverless.yml (for B and C)
- resources.serverless.yml
// ./services/A/serverless.yml
projectDir: ../../
functions:
A:
events:
- sqs:
arn: !Ref EventSomething
resources:
Resources: ${file(../../resources.serverless.yml):Resources}
// ./serverless.yml
functions:
C:
name: bee
resources:
Resources: ${file(./resources.serverless.yml):Resources}
// ./resources.serverless.yml
Resources:
EventSomething:
Type: AWS::SQS::Queue
EVENTC:
Type: AWS::SNS::Topic
Properties:
TopicName: ${file(./serverless.yml):functions.C.name}-DL
When i try to build and deploy A, this is the error i get
Cannot resolve serverless.yml: Variables resolution errored with:
- Cannot resolve variable at “resources.ResourcesEVENTC.Properties.TopicName”: Value not found at “file” source,
When i change the relative pathing in resources.serverless.yml
to ../../serverless.yml
, it works!
Clearly the file import’s relative path is all out of whack. If i do keep it to that then i can’t deploy my ./serverless.yml
as that relative path of ../../
would be wrong!
How can i achieve my setup? Or should i be thinking about this a different way.
Mainly i’m just trying to be DRY