1

When making a call to new pulumi.Config('someName') I would like to get an array of secrets that are under someName:aValue.

I've tried to call something like const cfg = new pulumi.Config('someName'), but after that, all the mothods under that class all call for a key (e.g. aValue), but that isn't helpful when wanting all secrets under the logical name.

pulumi.*.yaml

  someName:someValue1:
    secure: someSecureValue
  someName:someValue2:
    secure: someOtherSecureValue

somefile.ts

const cfg = new pulumi.Config('someName')

With the given code above, I'm looking for a list of all secrets under someName.

1 Answer 1

6

From the docs:

Configuration values are always stored as strings, but can be parsed as richly typed values.

For richer structured data, the config.getObject method can be used to parse JSON values.

For secret values, there are functions getSecretObject() and requireSecretObject(). For your example, you would do something like

pulumi config set --secret someName '{"someValue1": "someSecureValue", "someValue2": "someOtherSecureValue" }'

and then read it with

const config = new pulumi.Config();
const someName = config.requireSecretObject("someName");
const someValue1 = someName.someValue1;

Obviously, you could also use multiple secrets as separate keys in the config file and retrieve them one-by-one with separate requireSecretObject calls.

An array would be configured as

pulumi config set --secret someName '["someSecureValue", "someOtherSecureValue"]'
3
  • Your example shows someName with an array of secrets, but i need multiple someName:someValue1, and someName:someValue2 each with a value to be mapped. Not sure your example illustrates that, or else I'm missing it.
    – sh on
    Jul 2, 2019 at 2:14
  • @shon Edited it to use an object instead of an array Jul 2, 2019 at 5:53
  • Thx for updating, after the doc link you provided it pointed me in the right direction, and now that you've updated the answer I'll be voting this one up. Thank you.
    – sh on
    Jul 2, 2019 at 7:23

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.