Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2041 configure bigquery in the terraform module new dataset #2457

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/actions/deploy-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ runs:
with:
azure-credentials: ${{ inputs.azure-credentials }}

- uses: google-github-actions/auth@v2
with:
project_id: apply-for-qts-in-england
workload_identity_provider: projects/385922361840/locations/global/workloadIdentityPools/apply-for-qualified-teacher-sta3/providers/apply-for-qualified-teacher-sta3

- name: Apply Terraform
id: apply-terraform
shell: bash
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ jobs:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'deploy')
environment: review
permissions:
id-token: write
pull-requests: write

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -205,6 +209,9 @@ jobs:
url: ${{ steps.deploy.outputs.url }}
outputs:
environment_name: ${{ matrix.environment }}
permissions:
id-token: write
pull-requests: write

steps:
- uses: actions/checkout@v4
Expand All @@ -225,6 +232,9 @@ jobs:
name: production
url: ${{ steps.deploy.outputs.url }}
concurrency: deploy_production
permissions:
id-token: write
pull-requests: write

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/dfe_analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
disabled_by_default = Rails.env.development?
ENV.fetch("BIGQUERY_DISABLE", disabled_by_default.to_s) != "true"
end

config.azure_federated_auth = ENV.include? "GOOGLE_CLOUD_CREDENTIALS"
end
28 changes: 27 additions & 1 deletion terraform/application/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions terraform/application/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module "application_configuration" {
{
HOSTING_ENVIRONMENT = local.environment

BIGQUERY_PROJECT_ID = "apply-for-qts-in-england"
BIGQUERY_DATASET = "events_${var.app_environment}"
BIGQUERY_TABLE_NAME = "events"
BIGQUERY_PROJECT_ID = module.dfe_analytics.bigquery_project_id
BIGQUERY_DATASET = module.dfe_analytics.bigquery_dataset
BIGQUERY_TABLE_NAME = module.dfe_analytics.bigquery_table_name
})

secret_key_vault_short = "app"
Expand All @@ -32,6 +32,8 @@ module "application_configuration" {
AZURE_STORAGE_ACCOUNT_NAME = azurerm_storage_account.uploads.name
AZURE_STORAGE_ACCESS_KEY = azurerm_storage_account.uploads.primary_access_key
AZURE_STORAGE_CONTAINER = azurerm_storage_container.uploads.name

GOOGLE_CLOUD_CREDENTIALS = var.bigquery_federated_auth ? module.dfe_analytics.google_cloud_credentials : null
}
}

Expand Down Expand Up @@ -74,5 +76,6 @@ module "worker_application" {
command = ["bundle", "exec", "sidekiq", "-C", "./config/sidekiq.yml"]
probe_command = ["pgrep", "-f", "sidekiq"]

enable_logit = var.enable_logit
enable_logit = var.enable_logit
enable_gcp_wif = true
}
2 changes: 1 addition & 1 deletion terraform/application/config/review/Terrafile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dfe-terraform-modules:
source: https://github.com/DFE-Digital/terraform-modules
version: main
version: 2041-configure-bigquery-in-the-terraform-module-3
3 changes: 2 additions & 1 deletion terraform/application/config/review/variables.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"enable_logit": true,
"enable_monitoring": false,
"namespace": "tra-development",
"uploads_storage_environment_tag": "Test"
"uploads_storage_environment_tag": "Test",
"bigquery_federated_auth": true
}
1 change: 0 additions & 1 deletion terraform/application/config/review/variables.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
---
DQT_API_URL: https://dev.teacher-qualifications-api.education.gov.uk
BIGQUERY_DISABLE: true
17 changes: 17 additions & 0 deletions terraform/application/dfe_analytics.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
provider "google" {
project = "apply-for-qts-in-england"
}

module "dfe_analytics" {
source = "./vendor/modules/dfe-terraform-modules//aks/dfe_analytics"

azure_resource_prefix = var.azure_resource_prefix
cluster = var.cluster
namespace = var.namespace
service_short = var.service_short
environment = "${var.app_environment}${var.app_suffix}"
gcp_taxonomy_id = 5456044749211275650
gcp_policy_tag_id = 2399328962407973209
gcp_keyring = "afqts-key-ring"
gcp_key = "afqts-key"
}
6 changes: 6 additions & 0 deletions terraform/application/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ variable "uploads_storage_account_name" {
default = null
}

variable "bigquery_federated_auth" {
type = bool
default = false
description = "Configure environment variable to let dfe-analytics use federated authentication"
}

locals {
environment_variables = yamldecode(file("${path.module}/config/${var.app_environment}/variables.yml"))
}
Loading