2

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

MD TAREQ HASSAN
  • 1,188
  • 20
  • 46
  • What version of the Pulumi CLI are you using? I've tried what you say and if I add a new config setting then it reorders and removes the comments, but if I run `pulumi up -s dev` or `pulumi preview -s dev` nothing changes in the config file – Piers Karsenbarg Nov 12 '21 at 11:42
  • @PiersKarsenbarg using `v3.17.1`. I am changing stack settings file continuously since I am adding components one by one to my solution i.e. if AKS is done then adding Application Gateway, after Application Gateway will add Database, then VPN Gateway and so on... – MD TAREQ HASSAN Nov 12 '21 at 11:51
  • @PiersKarsenbarg regarding yaml comment, I just tested now for 3 times (`pulumi preview -s dev`) and it removed yaml comments all 3 times (even if I did not add any new config setting) – MD TAREQ HASSAN Nov 12 '21 at 11:57
  • @HassanTareq when running `up` or `preview`, is there a difference if you first run `pulumi stack select dev` and then just `pulumi preview` or `pulumi up` (without `-s` arg)? Please let us know if this made a difference. – Ringo De Smet Nov 14 '21 at 15:16
  • @RingoDeSmet same issue even after doing what you mentioned! – MD TAREQ HASSAN Nov 15 '21 at 05:31
  • **Workaround:** created Azure DevOps Pipeline and after every change, instead of deploying from local PC/VM, pushing the changes to DevOps repository and pipeline is deploying changes. – MD TAREQ HASSAN Nov 16 '21 at 05:08

1 Answers1

1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250