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

[2110] Enable dfe analytics federated authentication #3296

Merged
merged 2 commits into from
Dec 10, 2024
Merged
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
1 change: 0 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ DEACTIVATE_CANDIDATES=""
DFE_SIGNIN_API_ENABLED="1"
DFE_SIGNIN_API_SCHOOL_CHANGE_ENABLED="1"
GTM_ID=GTM-W3VGWP6
BIGQUERY_DATASET=gse_events_production
1 change: 0 additions & 1 deletion .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ DEACTIVATE_CANDIDATES=""
DFE_SIGNIN_API_ENABLED="1"
DFE_SIGNIN_API_SCHOOL_CHANGE_ENABLED="1"
GTM_ID=GTM-PN3BPDM
BIGQUERY_DATASET=gse_events_staging
5 changes: 5 additions & 0 deletions .github/workflows/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ runs:
;;
esac

- uses: google-github-actions/auth@v2
with:
project_id: get-into-teaching
workload_identity_provider: projects/574582782335/locations/global/workloadIdentityPools/schools-experience/providers/schools-experience

- name: Use Terraform ${{ env.TERRAFORM_VERSION }}
uses: hashicorp/setup-terraform@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ permissions:
issues: write
packages: write
pull-requests: write
id-token: write

env:
code-coverage-artifact-name: code_coverage_${{github.run_number}}_${{github.run_attempt}}
Expand Down Expand Up @@ -382,6 +383,7 @@ jobs:
concurrency: ${{matrix.environment}}_${{github.event.number}}
needs: [prepare]
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -544,7 +546,6 @@ jobs:
echo "::add-mask::$SECRET_VALUE"
echo "SLACK-WEBHOOK=$SECRET_VALUE" >> $GITHUB_OUTPUT


- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@master
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
pull_request:
types: [closed]

permissions:
id-token: write
pull-requests: write

jobs:
destroy:
name: Destroy
Expand All @@ -16,13 +20,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set Environment variables
shell: bash
run: |
tf_vars_file=terraform/aks/config/review.tfvars.json
terraform_version=$(awk '/{/{f=/^terraform/;next}f' terraform/aks/terraform.tf | grep -o [0-9\.]*)
echo "TERRAFORM_VERSION=$terraform_version" >> $GITHUB_ENV

- uses: google-github-actions/auth@v2
with:
project_id: get-into-teaching
workload_identity_provider: projects/574582782335/locations/global/workloadIdentityPools/schools-experience/providers/schools-experience

- name: Use Terraform ${{ env.TERRAFORM_VERSION }}
uses: hashicorp/setup-terraform@v3
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
description: Release Tag
required: true

permissions:
id-token: write

jobs:
manual:
name: Deploy to ${{github.event.inputs.environment}}
Expand All @@ -31,7 +34,7 @@ jobs:
- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Fetch slack token
uses: azure/CLI@v2
id: fetch-slack-secret
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 @@ -53,4 +53,6 @@
# config.environment = ENV.fetch('RAILS_ENV', 'development')

config.bigquery_maintenance_window = "08-09-2024 18:00..08-09-2024 19:00"

config.azure_federated_auth = ENV.include? "GOOGLE_CLOUD_CREDENTIALS"
end
22 changes: 21 additions & 1 deletion terraform/aks/.terraform.lock.hcl

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

7 changes: 7 additions & 0 deletions terraform/aks/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ module "application_configuration" {
ENVIRONMENT_NAME = var.environment
PGSSLMODE = local.postgres_ssl_mode
DFE_SIGNIN_BASE_URL = "https://${var.dsi_hostname}"
BIGQUERY_PROJECT_ID = "get-into-teaching"
BIGQUERY_TABLE_NAME = "events"
BIGQUERY_DATASET = var.dataset_name
}
secret_variables = {
DATABASE_URL = module.postgres[0].url
REDIS_URL = module.redis-cache[0].url

GOOGLE_CLOUD_CREDENTIALS = var.enable_dfe_analytics_federated_auth ? module.dfe_analytics[0].google_cloud_credentials : null
}
}

Expand Down Expand Up @@ -60,4 +65,6 @@ module "worker_application" {
enable_logit = var.enable_logit

enable_prometheus_monitoring = var.enable_prometheus_monitoring

enable_gcp_wif = true
}
3 changes: 2 additions & 1 deletion terraform/aks/config/development.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"sidekiq_memory_max" : "1Gi",
"dsi_hostname": "development.schoolexperience.education.gov.uk",
"enable_logit": true,
"enable_prometheus_monitoring": true
"enable_prometheus_monitoring": true,
"dataset_name": "gse_events_staging"
}
3 changes: 2 additions & 1 deletion terraform/aks/config/production.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
},
"dsi_hostname": "schoolexperience.education.gov.uk",
"enable_logit": true,
"enable_prometheus_monitoring": true
"enable_prometheus_monitoring": true,
"dataset_name": "gse_events_production"
}
4 changes: 3 additions & 1 deletion terraform/aks/config/review.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
"create_dsi_ingress": true,
"enable_logit": true,
"webapp_command": ["/app/docker-entrypoint.sh", "-e", "-f"],
"create_database": false
"create_database": false,
"enable_dfe_analytics_federated_auth": true,
"dataset_name": "gse_events_staging"
}
3 changes: 2 additions & 1 deletion terraform/aks/config/staging.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
},
"dsi_hostname": "staging.schoolexperience.education.gov.uk",
"enable_logit": true,
"enable_prometheus_monitoring": true
"enable_prometheus_monitoring": true,
"dataset_name": "gse_events_staging"
}
15 changes: 15 additions & 0 deletions terraform/aks/dfe_analytics.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
provider "google" {
project = "get-into-teaching"
}

module "dfe_analytics" {
count = var.enable_dfe_analytics_federated_auth ? 1 : 0
source = "./vendor/modules/aks//aks/dfe_analytics"

azure_resource_prefix = var.azure_resource_prefix
cluster = var.cluster
namespace = var.namespace
service_short = var.service_short
environment = var.environment
gcp_dataset = var.dataset_name
}
7 changes: 7 additions & 0 deletions terraform/aks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ variable "app_replicas" {
description = "number of replicas of the web app"
default = 1
}
variable "enable_dfe_analytics_federated_auth" {
description = "Create the resources in Google cloud for federated authentication and enable in application"
default = false
}
variable "dataset_name" {
description = "dfe analytics dataset name in Google Bigquery"
}

variable "enable_monitoring" {
default = false
Expand Down
Loading