Move database user provisioning to Terraform - #20
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
az ad sp showdeploy-infrastructure.ymland the preflight "Ensure Migration Principal Has DB Access" script frombuild-and-deploy.ymlChanges
.github/workflows/build-and-deploy.yml: Removed preflight database user provisioning step.github/workflows/deploy-infrastructure.yml: Removed object ID resolution step; addedTF_VAR_GITHUB_ACTIONS_APP_CLIENT_IDandTF_VAR_GITHUB_ACTIONS_INFRA_CLIENT_IDto Terraform plan and apply stepsInfra/variables.tf: Renamed object ID variables to client ID variables and updated localsInfra/prod/variables.tf: Changeddatabase_userstodatabase_users_client_idsInfra/prod/main.tf: Updated provisioner to accept client IDs and resolve object IDs at runtimeThe deployment now keeps all infrastructure provisioning concerns in Terraform, with the workflow simply passing the required credentials.