Skip to content

Commit

Permalink
Enable gcp wif in review env
Browse files Browse the repository at this point in the history
  • Loading branch information
RMcVelia committed Nov 25, 2024
1 parent f3775e2 commit 5682df6
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ runs:
with:
creds: ${{ inputs.azure-credentials }}

- uses: google-github-actions/auth@v2
with:
project_id: teaching-qualifications
workload_identity_provider: projects/708780292301/locations/global/workloadIdentityPools/check-childrens-barred-list/providers/check-childrens-barred-list

- name: Validate Azure Key Vault secrets
uses: DFE-Digital/github-actions/validate-key-vault-secrets@master
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ permissions:
deployments: write
packages: write
pull-requests: write
id-token: write

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ terraform-init: install-terrafile set-azure-account
$(eval export TF_VAR_config_short=$(CONFIG_SHORT))
$(eval export TF_VAR_service_short=$(SERVICE_SHORT))
$(eval export TF_VAR_rg_name=$(RESOURCE_GROUP_NAME))
$(eval export TF_VAR_config=${CONFIG})

terraform-plan: terraform-init
terraform -chdir=terraform/aks plan -var-file "config/${CONFIG}.tfvars.json"
Expand Down
1 change: 1 addition & 0 deletions config/initializers/dfe_analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
config.queue = :analytics
config.environment = HostingEnvironment.environment_name
config.entity_table_checks_enabled = true
config.azure_federated_auth = ENV.include? "GOOGLE_CLOUD_CREDENTIALS"

config.enable_analytics =
proc do
Expand Down
52 changes: 37 additions & 15 deletions terraform/aks/.terraform.lock.hcl

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

2 changes: 2 additions & 0 deletions terraform/aks/application.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module "worker_application" {
command = ["bundle", "exec", "sidekiq", "-C", "./config/sidekiq.yml"]
probe_command = ["pgrep", "-f", "sidekiq"]
enable_logit = var.enable_logit

enable_gcp_wif = true
}

module "application_configuration" {
Expand Down
3 changes: 2 additions & 1 deletion terraform/aks/config/review.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
],
"replicas": 1,
"memory_max": "1Gi",
"enable_logit": true
"enable_logit": true,
"enable_dfe_analytics_federated_auth": true
}
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 = "teaching-qualifications"
}

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 = "ccbl_events_${var.config}"
}
10 changes: 10 additions & 0 deletions terraform/aks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ variable "statuscake_contact_groups" {

variable "enable_logit" { default = false }

variable "enable_dfe_analytics_federated_auth" {
description = "Create the resources in Google cloud for federated authentication and enable in application"
default = false
}

variable "config" {
description = "Long name of the environment configuration, e.g. development, staging, production..."
}

locals {
service_name = "check-childrens-barred-list"
version = "1.9.7"
Expand Down Expand Up @@ -169,6 +178,7 @@ locals {
{
DATABASE_URL = module.postgres.url,
REDIS_URL = module.redis.url,
GOOGLE_CLOUD_CREDENTIALS = module.dfe_analytics[0].google_cloud_credentials
}
)
}

0 comments on commit 5682df6

Please sign in to comment.