Skip to content

Commit

Permalink
Migrate gcp-wif
Browse files Browse the repository at this point in the history
  • Loading branch information
vipin-dfe committed Jan 6, 2025
1 parent 66cdda2 commit 7d96db9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/actions/deploy-environment-to-aks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ runs:
with:
creds: ${{ inputs.azure-credentials }}

- uses: google-github-actions/auth@v2
with:
project_id: ecf-bq
workload_identity_provider: projects/808138694727/locations/global/workloadIdentityPools/early-careers-framework/providers/early-careers-framework

- name: Seed database
if: ${{ inputs.pull-request-number != '' }}
shell: bash
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ on:
pull_request:
merge_group:

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

jobs:
lint:
name: Lint
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/destroy_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
types: [closed]
branches: [main]

permissions:
id-token: write

jobs:
delete-review-app:
name: Delete Review App ${{ github.event.pull_request.number }}
Expand All @@ -19,6 +22,11 @@ jobs:
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: google-github-actions/auth@v2
with:
project_id: ecf-bq
workload_identity_provider: projects/808138694727/locations/global/workloadIdentityPools/early-careers-framework/providers/early-careers-framework

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.4
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 @@ -57,4 +57,6 @@
# users that don't use the id field.
#
config.user_identifier = proc { |user| user&.id if user.respond_to?(:id) }

config.azure_federated_auth = ENV.include? "GOOGLE_CLOUD_CREDENTIALS"
end
8 changes: 5 additions & 3 deletions terraform/application/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module "application_configuration" {
RAILS_ENV = var.app_environment
DB_SSLMODE = var.db_sslmode

BIGQUERY_PROJECT_ID = "ecf-bq",
BIGQUERY_DATASET = "events_${var.app_environment}", # TODO: work this out
BIGQUERY_TABLE_NAME = "events", # TODO: work this out
BIGQUERY_PROJECT_ID = "ecf-bq"
BIGQUERY_DATASET = var.dataset_name
BIGQUERY_TABLE_NAME = "events"
GIAS_API_SCHEMA = "https://ea-edubase-api-prod.azurewebsites.net/edubase/schema/service.wsdl"
GIAS_EXTRACT_ID = 13904
GIAS_API_USER = "ecftech"
Expand Down Expand Up @@ -65,6 +65,8 @@ module "web_application" {

enable_logit = var.enable_logit
send_traffic_to_maintenance_page = var.send_traffic_to_maintenance_page

enable_gcp_wif = true
}

module "worker_application" {
Expand Down
15 changes: 15 additions & 0 deletions terraform/application/dfe_analytics.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
provider "google" {
project = "ecf-bq"
}

module "dfe_analytics" {
count = var.enable_dfe_analytics_federated_auth ? 1 : 0
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/dfe_analytics?ref=testing"

azure_resource_prefix = var.azure_resource_prefix
cluster = var.cluster
namespace = var.namespace
service_short = var.service_short
environment = local.environment
gcp_dataset = var.dataset_name
}
10 changes: 10 additions & 0 deletions terraform/application/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,13 @@ variable "send_traffic_to_maintenance_page" {
default = false
description = "During a maintenance operation, keep sending traffic to the maintenance page instead of resetting the ingress"
}

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"
default = null
}
4 changes: 3 additions & 1 deletion terraform/application/workspace_variables/review.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"enable_monitoring": false,
"namespace": "cpd-development",
"db_sslmode": "prefer",
"enable_logit": true
"enable_logit": true,
"enable_dfe_analytics_federated_auth": true,
"dataset_name": "ecf_events_review"
}

0 comments on commit 7d96db9

Please sign in to comment.