https://pulumi.com logo
Title
s

square-hair-965

03/08/2023, 12:33 AM
Hello all! I'm building a cli using the
@pulumi/pulumi/automation
package and ran into something of a unique issue. The command is basically "disabling" an item in a map in the config but I'm having trouble updating the config with the new structure. Just piping the json object back into it using
setConfig
doesnt work. I get
object
strings. If I stringify as json, it ends up being a json string. I ended up installing the yaml package to help me do this but I'm still running into an issure. Currently the code looks like this:
await projectStack.setConfig('regions', { secret: false, value: yaml.stringify(newConfig) });
with
newConfig
being the updated config object i want to put back into the file as a yaml map
anyone have any ideas or insight?
for some additional context, this is what the map in the yaml looks like:
- cloudwatch_alarm_region: us-east-1
      enabled: false
      latency_region: us-east-1
      maintenance_override: false
      name: prod-us-east-1-blue
      region_id: us-east-1
      regional_stack: qa-us-east-1
      web_stack: prod-us-east-1-blue
    - cloudwatch_alarm_region: us-west-2
      enabled: true
      latency_region: us-west-2
      maintenance_override: false
      name: prod-us-west-2-blue
      region_id: us-west-2
      regional_stack: qa-us-west-2
      web_stack: prod-us-west-2-blue
    - cloudwatch_alarm_region: ap-southeast-2
      enabled: true
      latency_region: ap-southeast-2
      maintenance_override: false
      name: prod-ap-southeast-2-blue
      region_id: ap-southeast-2
      regional_stack: qa-ap-southeast-2
      web_stack: prod-ap-southeast-2-blue
After the update, it sets a
|
character at the beginning:
global-route53:regions: |
    - cloudwatch_alarm_region: us-east-1
      enabled: false
      latency_region: us-east-1
      maintenance_override: false
      name: prod-us-east-1-blue
      region_id: us-east-1
      regional_stack: qa-us-east-1
      web_stack: prod-us-east-1-blue
    - cloudwatch_alarm_region: us-west-2
      enabled: false
      latency_region: us-west-2
      maintenance_override: false
      name: prod-us-west-2-blue
      region_id: us-west-2
      regional_stack: qa-us-west-2
      web_stack: prod-us-west-2-blue
    - cloudwatch_alarm_region: ap-southeast-2
      enabled: true
      latency_region: ap-southeast-2
      maintenance_override: false
      name: prod-ap-southeast-2-blue
      region_id: ap-southeast-2
      regional_stack: qa-ap-southeast-2
      web_stack: prod-ap-southeast-2-blue
this seems to be the
setConfig
call doing this as console.logging the yaml.stringify call directly the | isn't there
digging through the code i found that it is calling a pulumi command, i'll likely have to call the cmd myself doing a
--path
option, harder than I thought grrr
l

little-cartoon-10569

03/08/2023, 2:43 AM
Can I query this statement?
Just piping the json object back into it using setConfig doesnt work. I get object strings.
Are those object strings the ones you get when you try to convert an Output to a string? That is, does your mapped object contain Outputs? You might be able to assign the map directly in the call to setConfig, if you setConfig inside an
apply()
.