Add workspaces_enabled toggle to gate the control-room workspaces step - #364
Conversation
The AWS WorkSpaces control-room step was unconditionally registered and always provisioned a WorkSpaces environment for every control room. Add a `workspaces_enabled` config toggle on AWSControlRoomConfig (default on via WorkspacesIsEnabled, mirroring EKSAccessEntriesConfig.IsEnabled) so a control room can opt out. When disabled the step no-ops before any credential fetch or Pulumi stack creation, so both the apply and destroy paths short-circuit cleanly.
|
Claude finished @stevenolen's task in 2m 35s —— View job Review
The implementation is clean and follows existing patterns well. One correctness concern worth addressing before merge, plus two minor observations posted as inline comments. Correctness concern (inline on Minor observations (non-blocking):
|
| slog.Info("skipping workspaces step: workspaces_enabled is false for this control room", | ||
| "target", s.DstTarget.Name()) | ||
| return nil | ||
| } |
There was a problem hiding this comment.
The destroy path has a silent-orphan risk: if a control room already has an active WorkSpaces Pulumi stack (real AWS resources) and someone then sets workspaces_enabled: false, any subsequent ptd ensure --destroy will hit this early return and leave those resources in AWS forever — the stack is never touched again.
The comment says "once the stack has been destroyed it stays gone", which assumes the operator already tore down before toggling, but that ordering isn't enforced. Consider at minimum a warning log when Destroy is set in Options and the gate fires:
if !cfg.WorkspacesIsEnabled() {
if s.Options.Destroy {
slog.Warn("workspaces step disabled but --destroy was requested; existing WorkSpaces stack will NOT be destroyed",
"target", s.DstTarget.Name())
} else {
slog.Info("skipping workspaces step: workspaces_enabled is false for this control room",
"target", s.DstTarget.Name())
}
return nil
}| // toggle off is also a no-op (once the stack has been destroyed it stays gone). | ||
| // Config is loaded the same way runAWSInlineGo loads it (helpers.ConfigForTarget + | ||
| // type-assert to AWSControlRoomConfig), which is the only control-room config kind. | ||
| rawConfig, err := helpers.ConfigForTarget(s.DstTarget) |
There was a problem hiding this comment.
runAWSInlineGo (in workspaces_aws.go:49-56) does the exact same ConfigForTarget + type-assert, so the config is parsed twice on the apply path. The struct is cheap to parse, so this isn't a performance issue, but it's a consistency hazard: if the type-assert error message or the config-load error format ever diverges between the two call sites, debugging gets confusing.
Not blocking, but worth noting if this pattern gets copied further.
| // WorkspacesEnabled is explicitly set to false. The nil → true default preserves | ||
| // the historical always-on behavior of the AWS WorkSpaces step, mirroring how | ||
| // EKSAccessEntriesConfig.IsEnabled treats an absent flag as enabled. | ||
| func (c AWSControlRoomConfig) WorkspacesIsEnabled() bool { |
There was a problem hiding this comment.
Minor inconsistency with EKSAccessEntriesConfig.IsEnabled() (line 21), which has a pointer receiver (c *EKSAccessEntriesConfig) that also handles c == nil. WorkspacesIsEnabled uses a value receiver (c AWSControlRoomConfig), which is fine since AWSControlRoomConfig is never used via pointer here, but the parallel drawn in the doc comment is slightly misleading — the nil-receiver guard in IsEnabled doesn't apply here.
Description
The control-room
workspacesstep (AWS WorkSpaces virtual desktops) was unconditionally registered inControlRoomStepsand always provisioned a WorkSpaces environment for every control room, with no way to opt out. This adds aworkspaces_enabledconfig toggle so a control room can turn the step off.Code Flow
AWSControlRoomConfiggainsWorkspacesEnabled *bool(workspaces_enabled). It is a pointer so an absent field is distinguishable from an explicitfalse.WorkspacesIsEnabled()resolves it, defaulting to on when unset (nil -> true), mirroringEKSAccessEntriesConfig.IsEnabled(). This preserves the historical always-on behavior; only an explicitworkspaces_enabled: falsedisables the step.WorkspacesStep.Runloads the control-room config (viahelpers.ConfigForTarget, the same wayrunAWSInlineGodoes) right after theControlRoom()validation and before any credential fetch or Pulumi stack construction. When disabled it logs and returns nil, so both the apply and--destroypaths short-circuit identically.Category of change
Checklist