How to prevent Pulumi cli from shuffling configurations in stack settings file

Viewed 242

I am trying to organize configuration values in stack settings file (Pulumi.dev.yaml) from top to bottom sequentially i.e. first Resource Group, then Storage Account, then Virtual Network, AKS and so on as following:

secretsprovider: xxx
encryptedkey: xxx
config:
  azure-native:location: japaneast

  #
  # Resource Group
  #
  ns:MainResourceGroupArgs:
    ResourceGroupName: xxx
    Tags:
      TestTag: xxx
  #
  # Storage Account
  #
  ns:MainStorageAccountArgs:
    AccountKind: StorageV2
    AccountName: xxxsa
    AccountSku: Standard_LRS
    Tags:
      TestTag: xxx
  #
  # Spoke VNet
  #
  ns:SpokeVirtualNetworkArgs:
    AddressPrefixes:
    - 10.10.0.0/18
    Subnets:
      # ... ... ...
  #
  # Hub VNet
  #
  # ... ... ...

  #
  # AKS
  #
  # ... ... ...

But every time a Pulumi command is executed (i.e. pulumi preview -s dev or pulumi up -s dev) followings are happening:

  1. configuration values are being shuffled, for example before executing command Resource Group was at top but after executing command Resource Group is at bottom. This is very annoying and bad when we have huge number of configurations
  2. yaml comments are being removed

How to solve this issue?

I want to keep yaml comments in stack settings file and prevent Pulumi cli from shuffling configuration values.

Info: Pulumi cli v3.17.1

1 Answers

With Pulumi 3.24.1 and PULUMI_EXPERIMENTAL=true, you might check if Pulumi.dev.yaml has its content still reshuffled after:

 pulumi preview -s dev --save-plan plan.json 

Because after that, you can do:

 pulumi up --plan-file plan.json

See:

Announcing the public preview of Update Plans

Before today, there is no guarantee that the pulumi up operation will do only what was previewed; if the program, or your infrastructure, changes between the preview and the update, the update might make additional changes to bring your infrastructure back in line with what’s defined in your program.

We’ve heard from many of you that you need a strong guarantee about exactly which changes an update will make to your infrastructure, especially in critical and production environments.

Today (Feb. 9th, 2022), I’m excited to announce the public preview of Update Plans, a new Pulumi feature which guarantees that operations shown in pulumi preview will run on pulumi up.

Update Plans also help catch any unexpected changes that might happen between when you preview a change and when you apply that change.

Update Plans work by saving the results of a pulumi preview to a plan file, which enables you to restrict subsequent pulumi up operations to only the actions saved in the plan file.
This helps you ensure that what you saw in the pulumi preview is what will actually happen when you run pulumi up.

Related