Closed wcx628 closed 2 years ago
@wcx628 thanks for reporting. Still I cannot reproduce that.
I've created test service that resolves a StrinLing type SSM variable (of value marko,valo,elo
), and via ~split
I resolve it into array:
https://github.com/medikoo/test-serverless/blob/variables-ssm/serverless.yml#L12
And it works as expected, which we can confirm in serverless-state.json
file:
I'm using v2.1.1
I have also installed docker 19, node.js 10, could that be the problem? My actual StringList is 'subnet-0cf92386d8f5cd7ff,subnet-0d1b4b85edf6db410,subnet-09913cf0354699087'
@wcx628 I have no idea. Generally as you see it works properly in simple service case. Probably you should investigate what configuration on your side breaks it
I had this same issue with a build yesterday. Both jobs were run by CodeBuild so there were no manual changes other than setting the version in the successful run.
In serverless, it looks like this: subnetIds: ${ssm:/myApp/vpc/subnets/app~split}
2020/09/17 19:54:37 Running command npm install serverless -g
. . .
serverless@2.1.1
. . .
serverless print
. . .
subnetIds: 'subnet-0cf92386d8f5cd7ff,subnet-0d1b4b85edf6db410,subnet-09913cf0354699087'
2020/09/17 20:28:42 Running command npm install serverless@1.77.1 -g
. . .
serverless@1.77.1
. . .
subnetIds:
--
- subnet-0cf92386d8f5cd7ff
- subnet-0d1b4b85edf6db410
- subnet-09913cf0354699087
@kkress2000 can you prepare as minimal as possible, reproducible test case, so I can run it in my environment (it should not involve any plugins)
@medikoo My first attempt to re-create has failed. I'm wondering whether this is related to boto issue that occurred last Thursday (17 Sept.). I got bit by that too. I'll keep trying to either re-create this problem or verify that the boto issue was a momentary glitch now healed.
A different but related question. In a Typescript
version with serverless.ts
, subnetIds
is declared as string[]
and I basically can't use the same ~split
technique as I was able to do in serverless.yml
. I either get an unsplit string from the SSM's StringList
without the ~split
or an array of arrays with ~split
.
It's probably better to declare the type as string | string[]
and then either wrap a simple string into an array or delegate to Fn::Split
to produce an array out of the StringList
? I guess I got to find where it's done and propose a PR
I guess I got to find where it's done and propose a PR
@pveller thanks for reporting. Still in context of this project we only maintain JSON Schema for config validation. TypeScript types is handled by community externally (core team does not guarantee it to be correct or up to date), I believe it's handled here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/serverless/index.d.ts)
If I try to use the ~split
option at the end of an SSM parameter, I'll get this error: Parameter name: can't be prefixed with "ssm" (case-insensitive). If formed as a path, it can consist of sub-paths divided by slash symbol; each sub-path can be formed as a mix of letters, numbers and the following 3 symbols .-_
.
subnetIds: ${ssm:/subnets~split}
However, if I remove the ~split
, it will be smart enough to detect it is a string list and correctly split the resources accordingly, so the correct way to use it is like:
subnetIds: ${ssm:/subnets}
PS. I'm using serverless v2.59.0
I'm going to close this as we have no response from author of thread, and no issue was confirmed
@rodrigomata ~split
is a format used by old variables resolver which will be no longer working in v3 of Framework.
New resolver automatically splits the string into tokens if it detects StringList
type
With the new version release, the split function {~split} no longer works
service: test provider: vpc: subnetIds: ${ssm:/test/vpc/subnets/app~split}serverless.yml
Installed version
version is serverless 2.1.1