Skip to content

Fetch Azure bastion SSH key from Pulumi state#172

Open
Lytol wants to merge 1 commit intomainfrom
bs-azure-bastion-keys
Open

Fetch Azure bastion SSH key from Pulumi state#172
Lytol wants to merge 1 commit intomainfrom
bs-azure-bastion-keys

Conversation

@Lytol
Copy link
Contributor

@Lytol Lytol commented Mar 10, 2026

Description

The Azure bastion SSH key was previously written to ~/.ssh/ during pulumi up via a local.run_output command. This only worked for the engineer who ran the initial deployment — other engineers couldn't connect because the key wasn't on their machine.

This PR exports the SSH key as a Pulumi stack output and fetches it on demand when starting a proxy session.

Code Flow

  1. Python: The bastion SSH private key is exported as a secret stack output (bastion_ssh_private_key) from the persistent stack via azure_workload_persistent.py.
  2. Go (target.go): BastionName() and JumpBoxId() are consolidated into a single BastionInfo() method that fetches all bastion connection details (name, jumpbox ID, SSH key) from the persistent stack in one lookup.
  3. Go (proxy.go): When starting a proxy session, the SSH key is written to a temp file via os.CreateTemp, used for the SSH SOCKS connection, and cleaned up in Stop().
  4. Go (workon.go): PTD_ROOT is now exported to the workon shell environment so that pulumi commands work correctly within the shell.

Rollout

The bastion_ssh_private_key output must be registered via pulumi up on the persistent stack for each Azure workload before deploying the new binary. I will run ensure on all Azure workloads so the new stack output is in place for everyone before merging.

Category of change

  • New feature (non-breaking change which adds functionality)
  • Refactor: a code change that neither fixes a bug nor adds a feature

…stem

Previously, the bastion SSH key was written to ~/.ssh/ during `pulumi up`
via a local command, which only worked for the engineer who ran the initial
deployment. Other engineers would fail to connect because the key wasn't
on their machine.

Now the SSH key is exported as a Pulumi stack output and fetched on demand
when starting a proxy session. The key is written to a temp file and
cleaned up when the proxy stops.

Additional changes:
- Consolidate BastionName/JumpBoxId into single BastionInfo lookup
- Export PTD_ROOT in workon shell for manual pulumi commands
- Remove local.run_output that wrote SSH key to ~/.ssh/
@Lytol Lytol requested a review from a team as a code owner March 10, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant