pulumi / pulumi-kubernetes-operator

A Kubernetes Operator that automates the deployment of Pulumi Stacks
Apache License 2.0
218 stars 55 forks source link

Use a per-stack PULUMI_HOME directory #490

Closed EronWright closed 11 months ago

EronWright commented 12 months ago

Proposed changes

Closes #483

This PR seeks to isolate the credentials associated with a given Stack, to solve the problem of credentials leaking across stacks. Some underlying details here:

  1. Pulumi CLI stores login credentials in PULUMI_HOME (e.g. ~/.pulumi/credentials.json).
  2. A side-effect of using PULUMI_ACCESS_TOKEN is that the CLI login credentials are set.
  3. Pulumi CLI prefers the persisted login credentials to PULUMI_ACCESS_TOKEN.

This PR takes the conservative approach of encapsulating the PULUMI_HOME into a per-stack working directory, as opposed to reusing ~/.pulumi across stacks. The working directory is retained across reconciliation passes, and cleaned up during stack finalization. Note that the workspace directory is erased at the end of each reconciliation pass, as is the current behavior.

This PR does NOT solve the (lack of) mutability of PULUMI_ACCESS_TOKEN across stack updates.

Note that this PR contains some commits (related to hacking on the operator) that will be moved to a separate PR.

Technical Details

Relevant terminology used within the controller codebase:

The current behavior of the operator is to erase the workspace directory on each reconciliation pass, e.g. to ensure a clean git checkout. This PR retains this behavior while keeping the home directory across passes, e.g. to reuse the providers.

Related issues (optional)