I'm starting to write some templates and ran into ...
# general
f
I'm starting to write some templates and ran into some trouble making a template config with a default for aws:allowedAccountIds, since it's a list. ā€¢ if you specify the default as a plain scalar,
pulumi up
fails with
Attribute must be a list
ā€¢ if you try to specify the default as a list,
pulumi new
fails with
cannot unmarshal !!seq into string
The workaround I found that does work, is to put the list (which in my case is always just a single account id) in quotes:
Copy code
template:
  config:
    aws:allowedAccountIds:
      description: aws account ids to deploy to (must be in brackets)
      default: '[1234567890]'
If you accept the default, it shows up in the stack config as
Copy code
config:
  aws:allowedAccountIds: '[1234567890]'
which looks goofy, but works. Also, users of the template must still put their account id in brackets if they're not using the default account id, which is not great. Anyone have a better solution?
s
does this work by chance?
Copy code
template:
  config:
    aws:allowedAccountIds:
      description: aws account
      default:
        - 1234567890
f
No, that gives you the
cannot unmarshal !!seq into string
error I mentioned
Apparently the template config defaults are only supported as strings. The workaround I found only works because the string '[1234567890]' gets parsed as a list once it's in the stack config
s
yeah that certainly doesn't feel good but I see how that would work if you have no choice but to give it a string as input šŸ˜•
f
šŸ¤·ā€ā™‚ļø
s
yeah lol
if your users are going to be mind blown I have other ideas that are much more work but unless it's a big problem they will probably be able to figure it out
f
it's other developers so I think they'll be fine, they'll just feel slightly uncomfortable lol
s
hahahah yeah
throw in a
# this is a list inside a string. Yes it's weird.
lol