You can inject outputs from one service into another using the ${service.outputName} syntax. This creates an implicit dependency, causing osls to deploy the provider service first.
- Expose Output: In the provider service's
serverless.yml, define the value in the resources.Outputs section. - Pass Parameter: In
serverless-compose.yml, reference the output under the params key of the consumer service. - Consume Parameter: In the consumer service's
serverless.yml, access the value using the ${param:parameterName} syntax.
Important: If a service uses ${param:...}, you must run commands from the root using the service-specific syntax (e.g., osls service-a:deploy) because ${param:...} cannot be resolved outside of the osls compose context.
# serverless-compose.yml
services:
service-a:
path: service-a
service-b:
path: service-b
params:
queueUrl: ${service-a.queueUrl}
# service-a/serverless.yml
resources:
Resources:
MyQueue:
Type: AWS::SQS::Queue
Outputs:
queueUrl:
Value: !Ref MyQueue
# service-b/serverless.yml
provider:
environment:
SERVICE_A_QUEUE_URL: ${param:queueUrl}