Skip to content

Move database user provisioning to Terraform - #20

Merged
Keboo merged 5 commits into
mainfrom
keboo/psychic-fishstick
May 22, 2026
Merged

Move database user provisioning to Terraform#20
Keboo merged 5 commits into
mainfrom
keboo/psychic-fishstick

Conversation

@Keboo

@Keboo Keboo commented May 22, 2026

Copy link
Copy Markdown
Owner

Problem

Database deployment was failing due to missing SQL user provisioning. Object IDs were being resolved in GitHub Actions workflow but this created a separation of concerns—infrastructure provisioning logic was split between workflow scripts and Terraform.

Solution

Moved all database user provisioning logic into Terraform where infrastructure concerns belong:

  • Terraform now handles object ID resolution: Instead of passing pre-resolved object IDs from the workflow, Terraform now accepts service principal client IDs and resolves the corresponding object IDs at provisioning time using az ad sp show
  • Workflow simplified: Removed the "Resolve Service Principal Object IDs" step from deploy-infrastructure.yml and the preflight "Ensure Migration Principal Has DB Access" script from build-and-deploy.yml
  • Single source of truth: All database user provisioning is now managed by Terraform, eliminating duplication and keeping infrastructure concerns in infrastructure-as-code

Changes

  • .github/workflows/build-and-deploy.yml: Removed preflight database user provisioning step
  • .github/workflows/deploy-infrastructure.yml: Removed object ID resolution step; added TF_VAR_GITHUB_ACTIONS_APP_CLIENT_ID and TF_VAR_GITHUB_ACTIONS_INFRA_CLIENT_ID to Terraform plan and apply steps
  • Infra/variables.tf: Renamed object ID variables to client ID variables and updated locals
  • Infra/prod/variables.tf: Changed database_users to database_users_client_ids
  • Infra/prod/main.tf: Updated provisioner to accept client IDs and resolve object IDs at runtime

The deployment now keeps all infrastructure provisioning concerns in Terraform, with the workflow simply passing the required credentials.

KebooIntelliTect and others added 5 commits May 21, 2026 16:40
Switch deploy-database Azure Login to ARM_CLIENT_ID/TENANT/SUBSCRIPTION so migration runs under the same principal pattern as SpectralTabletop.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a deploy-database preflight step that provisions GillyTracker-GitHubActions in the existing SQL database with required roles before running efbundle.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Populate TF_VAR_GITHUB_ACTIONS_*_OBJECT_ID from az ad sp lookups so Terraform no longer receives empty values and removes DB user provisioning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove object ID resolution from GitHub Actions workflow
- Refactor Terraform to accept client IDs as inputs and resolve object IDs within the provisioner
- Update deploy-infrastructure workflow to pass client IDs directly to Terraform
- Remove preflight database user setup from build-and-deploy workflow
- All database user provisioning now handled by Terraform, keeping infrastructure concerns in IaC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use Terraform data source instead of 'az ad sp show' CLI command to resolve
service principal object IDs. This is more idiomatic, eliminates CLI dependency
in provisioner, and reduces potential for transient CLI failures.

Bumped trigger version to v3 to force re-provisioning with new approach.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Keboo
Keboo merged commit 85bc6b4 into main May 22, 2026
2 checks passed
@Keboo
Keboo deleted the keboo/psychic-fishstick branch May 22, 2026 00:35
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.

2 participants