diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index 60efdad3..1cef69ad 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -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: diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 2bb945e3..cd2e0e1e 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -25,6 +25,7 @@ permissions: deployments: write packages: write pull-requests: write + id-token: write jobs: build: diff --git a/Makefile b/Makefile index acdcbfc9..95bf85fb 100644 --- a/Makefile +++ b/Makefile @@ -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" diff --git a/config/initializers/dfe_analytics.rb b/config/initializers/dfe_analytics.rb index 6f4c1826..546d36a2 100644 --- a/config/initializers/dfe_analytics.rb +++ b/config/initializers/dfe_analytics.rb @@ -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 diff --git a/terraform/aks/.terraform.lock.hcl b/terraform/aks/.terraform.lock.hcl index 3faa3de8..972564cd 100644 --- a/terraform/aks/.terraform.lock.hcl +++ b/terraform/aks/.terraform.lock.hcl @@ -27,8 +27,9 @@ provider "registry.terraform.io/eppo/environment" { provider "registry.terraform.io/hashicorp/azurerm" { version = "3.116.0" - constraints = "3.116.0" + constraints = ">= 3.0.0, 3.116.0" hashes = [ + "h1:2QbjtN4oMXzdA++Nvrj/wSmWZTPgXKOSFGGQCLEMrb4=", "h1:BCR3NIorFSvGG3v/+JOiiw3VM4PkChLO4m84wzD9NDo=", "zh:02b6606aff025fc2a962b3e568e000300abe959adac987183c24dac8eb057f4d", "zh:2a23a8ce24ff9e885925ffee0c3ea7eadba7a702541d05869275778aa47bdea7", @@ -45,11 +46,32 @@ provider "registry.terraform.io/hashicorp/azurerm" { ] } +provider "registry.terraform.io/hashicorp/google" { + version = "6.6.0" + constraints = "6.6.0" + hashes = [ + "h1:bNj7UyO9+IdcTbkZJgjULH89DrJSaBCRw89zt6g8ajg=", + "zh:0c181f9b9f0ab81731e5c4c2d20b6d342244506687437dad94e279ef2a588f68", + "zh:12a4c333fc0ba670e87f09eb574e4b7da90381f9929ef7c866048b6841cc8a6a", + "zh:15c277c2052df89429051350df4bccabe4cf46068433d4d8c673820d9756fc00", + "zh:35d1663c81b81cd98d768fa7b80874b48c51b27c036a3c598a597f653374d3c8", + "zh:56b268389758d544722a342da4174c486a40ffa2a49b45a06111fe31c6c9c867", + "zh:abd3ea8c3a62928ba09ba7eb42b52f53e682bd65e92d573f1739596b5a9a67b1", + "zh:be55a328d61d9db58690db74ed43614111e1105e5e52cee15acaa062df4e233e", + "zh:ce2317ce9fd02cf14323f9e061c43a415b4ae9b3f96046460d0e6b6529a5aa6c", + "zh:d54a6d8e031c824f1de21b93c3e01ed7fec134b4ae55223d08868c6168c98e47", + "zh:d8c6e33b5467c6eb5a970adb251c4c8194af12db5388cff9d4b250294eae4daa", + "zh:f49e4cc9c0b55b3bec7da64dd698298345634a5df372228ee12aa45e57982f64", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} + provider "registry.terraform.io/hashicorp/kubernetes" { version = "2.32.0" constraints = "2.32.0" hashes = [ "h1:3j4XBR5UWQA7xXaiEnzZp0bHbcwOhWetHYKTWIrUTI0=", + "h1:Cj3RHyw3wE3AkNlCtSNrZfjFNkShvaZR0K/K3pJlYJU=", "zh:0e715d7fb13a8ad569a5fdc937b488590633f6942e986196fdb17cd7b8f7720e", "zh:495fc23acfe508ed981e60af9a3758218b0967993065e10a297fdbc210874974", "zh:4b930a8619910ef528bc90dae739cb4236b9b76ce41367281e3bc3cf586101c7", @@ -66,22 +88,21 @@ provider "registry.terraform.io/hashicorp/kubernetes" { } provider "registry.terraform.io/hashicorp/random" { - version = "3.6.2" + version = "3.6.3" hashes = [ - "h1:R5qdQjKzOU16TziCN1vR3Exr/B+8WGK80glLTT4ZCPk=", - "h1:VavG5unYCa3SYISMKF9pzc3718M0bhPlcbUZZGl7wuo=", - "zh:0ef01a4f81147b32c1bea3429974d4d104bbc4be2ba3cfa667031a8183ef88ec", - "zh:1bcd2d8161e89e39886119965ef0f37fcce2da9c1aca34263dd3002ba05fcb53", - "zh:37c75d15e9514556a5f4ed02e1548aaa95c0ecd6ff9af1119ac905144c70c114", - "zh:4210550a767226976bc7e57d988b9ce48f4411fa8a60cd74a6b246baf7589dad", - "zh:562007382520cd4baa7320f35e1370ffe84e46ed4e2071fdc7e4b1a9b1f8ae9b", - "zh:5efb9da90f665e43f22c2e13e0ce48e86cae2d960aaf1abf721b497f32025916", - "zh:6f71257a6b1218d02a573fc9bff0657410404fb2ef23bc66ae8cd968f98d5ff6", + "h1:f6jXn4MCv67kgcofx9D49qx1ZEBv8oyvwKDMPBr0A24=", + "zh:04ceb65210251339f07cd4611885d242cd4d0c7306e86dda9785396807c00451", + "zh:448f56199f3e99ff75d5c0afacae867ee795e4dfda6cb5f8e3b2a72ec3583dd8", + "zh:4b4c11ccfba7319e901df2dac836b1ae8f12185e37249e8d870ee10bb87a13fe", + "zh:4fa45c44c0de582c2edb8a2e054f55124520c16a39b2dfc0355929063b6395b1", + "zh:588508280501a06259e023b0695f6a18149a3816d259655c424d068982cbdd36", + "zh:737c4d99a87d2a4d1ac0a54a73d2cb62974ccb2edbd234f333abd079a32ebc9e", "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:9647e18f221380a85f2f0ab387c68fdafd58af6193a932417299cdcae4710150", - "zh:bb6297ce412c3c2fa9fec726114e5e0508dd2638cad6a0cb433194930c97a544", - "zh:f83e925ed73ff8a5ef6e3608ad9225baa5376446349572c2449c0c0b3cf184b7", - "zh:fbef0781cb64de76b1df1ca11078aecba7800d82fd4a956302734999cfd9a4af", + "zh:a357ab512e5ebc6d1fda1382503109766e21bbfdfaa9ccda43d313c122069b30", + "zh:c51bfb15e7d52cc1a2eaec2a903ac2aff15d162c172b1b4c17675190e8147615", + "zh:e0951ee6fa9df90433728b96381fb867e3db98f66f735e0c3e24f8f16903f0ad", + "zh:e3cdcb4e73740621dabd82ee6a37d6cfce7fee2a03d8074df65086760f5cf556", + "zh:eff58323099f1bd9a0bec7cb04f717e7f1b2774c7d612bf7581797e1622613a0", ] } @@ -90,6 +111,7 @@ provider "registry.terraform.io/statuscakedev/statuscake" { constraints = "2.2.2" hashes = [ "h1:nVaJkDBk4sv0yWFzg3p+yeJGzE8mB4KJv3Q6/UgU164=", + "h1:wFoZJfmNvG6XTf65NLai67geSHqYV1Tilx7OITrHilE=", "zh:0916313344c579d6e05d70f88129a10fe48f7dabe0e61cad17874d6c496f288d", "zh:0d491ff72c2eda6482855033ca2146c5ace1663d07cb3da7253b59ed2e2ec6f4", "zh:11fffbce18eb3d3c283e877242f477e0c561342c19090240b60af7d948bd84ac", diff --git a/terraform/aks/application.tf b/terraform/aks/application.tf index 7ddd515f..fa904f3a 100644 --- a/terraform/aks/application.tf +++ b/terraform/aks/application.tf @@ -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" { diff --git a/terraform/aks/config/review.tfvars.json b/terraform/aks/config/review.tfvars.json index f87ca5f1..1ca9808b 100644 --- a/terraform/aks/config/review.tfvars.json +++ b/terraform/aks/config/review.tfvars.json @@ -17,5 +17,6 @@ ], "replicas": 1, "memory_max": "1Gi", - "enable_logit": true + "enable_logit": true, + "enable_dfe_analytics_federated_auth": true } diff --git a/terraform/aks/dfe_analytics.tf b/terraform/aks/dfe_analytics.tf new file mode 100644 index 00000000..2e1fcf89 --- /dev/null +++ b/terraform/aks/dfe_analytics.tf @@ -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}" +} diff --git a/terraform/aks/variables.tf b/terraform/aks/variables.tf index 8ddb9976..512fbbcb 100644 --- a/terraform/aks/variables.tf +++ b/terraform/aks/variables.tf @@ -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" @@ -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 } ) }