How to read string array from SSM to serverless yaml

My serverless is like this:
service: {self:provider.deployVersion}-cph-{opt:service}
provider:
vpc:
securityGroupIds:
- sg-xxx
subnetIds:
- subnet-xxx
- subnet-xxx
- subnet-xxx
stage: ${opt:stage, ‘dev’}

How can i move all vpc variables into a single system parameter store variable so that serverless reads them properly? I tried to same the whole block in SSM but at time of reading, serverless is reading like below : Not sure why |- is getting appended
vpc: |-
securityGroupIds:
- sg-xx
subnetIds:
- subnet-xx
- subnet-xx
- subnet-xx

You can split an SSM string into a list with this syntax:
ssm_var_split: { 'Fn::Split': [ ",", "${ssm:x}" ] }

1 Like