https://pulumi.com logo
#general
Title
# general
f

fresh-spring-82225

01/25/2024, 7:29 PM
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

stale-twilight-75626

01/25/2024, 9:11 PM
does this work by chance?
Copy code
template:
  config:
    aws:allowedAccountIds:
      description: aws account
      default:
        - 1234567890
f

fresh-spring-82225

01/25/2024, 9:20 PM
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

stale-twilight-75626

01/25/2024, 9:22 PM
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

fresh-spring-82225

01/25/2024, 9:29 PM
šŸ¤·ā€ā™‚ļø
s

stale-twilight-75626

01/25/2024, 9:29 PM
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

fresh-spring-82225

01/25/2024, 9:33 PM
it's other developers so I think they'll be fine, they'll just feel slightly uncomfortable lol
s

stale-twilight-75626

01/25/2024, 9:33 PM
hahahah yeah
throw in a
# this is a list inside a string. Yes it's weird.
lol