Pulumi state
The sundial-api Pulumi stacks moved from Pulumi Cloud to a self-managed S3 backend on 7 November 2026. This page says where each stack lives, how to use it, and how the move was done.
Why
Pulumi Cloud bills the sundialenergy organisation per resource-hour. In October 2026 that was US$74 for 397 resources. Its free plan allows one user and no organisation, so the only way to US$0 is a backend we host. The state bucket costs cents and the KMS key US$1 a month.
Where each stack lives
One backend per AWS account:
| Environment | AWS account | Backend URL | Stack name |
|---|---|---|---|
| dev | 438269071322 | s3://sundial-pulumi-state-dev?region=ap-southeast-2 |
organization/sundial-api/dev |
| prod | 628060125155 | s3://sundial-pulumi-state-prod?region=ap-southeast-2 |
organization/sundial-api/prod |
The bucket and the KMS key alias/pulumi-secrets in each account come from cloudformation/pulumi-state-backend.yml in gitlab.com/sundial1/infrastructure, deployed by that project's pulumi-backend-<env> CI job. Stack secrets use the secrets provider awskms://alias/pulumi-secrets?region=ap-southeast-2, so anyone with AWS credentials for the account can read and write them. There is no passphrase.
Using a stack on S3
Set PULUMI_BACKEND_URL and use AWS credentials for that account. There is no pulumi login step and no Pulumi access token.
export PULUMI_BACKEND_URL="s3://sundial-pulumi-state-dev?region=ap-southeast-2"
pulumi stack output rdsDbPassword --show-secrets -s organization/sundial-api/dev
In CI, the .pulumi-backend-<env> block in .gitlab-ci.yml sets PULUMI_BACKEND_URL and PULUMI_STACK for the jobs of that environment. The scripts in scripts/ fall back to the Pulumi Cloud stack name when PULUMI_STACK is unset.
Moving a stack
Both stacks have moved. The steps stay here for the other Sundial projects and as the record of how it was done.
The CI scripts take the stack name from PULUMI_STACK and fall back to the Pulumi Cloud name. The hidden .pulumi-backend-dev and .pulumi-backend-prod blocks in .gitlab-ci.yml hold the backend URL and stack name for each environment. Each block also sets a resource_group, so GitLab runs one Pulumi job per stack at a time. Every operation on the S3 backend takes a lock file in the bucket. To move an environment:
- Check that the infrastructure project's
pulumi-backend-<env>job has run, so the bucket and key exist. Both accounts had them on 7 November 2026. - Run the manual job
pulumi-migrate-<env>: on the latest master pipeline for dev, on a tag pipeline for prod. It runsscripts/migrate-pulumi-state.sh <env>with the pinned Pulumi CLI,PULUMI_ACCESS_TOKENand the environment's AWS credentials. The script copies the stack withpulumi stack migrate, rewritesPulumi.<env>.yamlwith the KMS secrets provider, and the job keeps that file as an artifact. The Pulumi Cloud copy stays in place. The job runs afterpulumi-<env>, so the copy includes that pipeline's deploy. - Download the
Pulumi.<env>.yamlartifact and open an MR with it,extends: [.., .pulumi-backend-<env>]on the four<env>jobs (pulumi-preview-<env>,pulumi-<env>,migrate-aws-<env>,register-schedules-aws-<env>), and the doc and script updates for the new stack name. The MR pipeline'spulumi-preview-<env>job is the proof: it previews against S3 and must show no change the Pulumi Cloud preview would not show. For prod that proof comes on the tag pipeline, because the prod credentials are protected CI variables. - If anything deploys the Pulumi Cloud stack between steps 2 and 3, the S3 copy is stale. Run
pulumi-migrate-<env>again on the pipeline that deployed: the script replaces the stale copy. Once the switch MR has merged, the script refuses to run, because the S3 copy is then the live state. - Merge. Check the
<env>deploy jobs pass andpulumi upreports no unexpected changes. - Delete the Pulumi Cloud stack so nothing deploys it by mistake:
pulumi stack rm sundialenergy/sundial-api/<env> --forcewhile logged in to Pulumi Cloud.--forceremoves the state record only; the AWS resources stay.
After every stack in the organisation has moved, downgrade the sundialenergy organisation in Pulumi Cloud to stop the subscription.