diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 3578c0aa5..4f97b1cba 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -44,6 +44,7 @@ jobs: TF_VAR_ssh_private_key: ${{ secrets.ssh_private_key }} TF_VAR_public_hostname: ${{ vars.PUBLIC_HOSTNAME }} TF_VAR_airflow__core__fernet_key: ${{ secrets.AIRFLOW__CORE__FERNET_KEY }} + TF_VAR_api_token_enabled: ${{ vars.api_token_enabled }} ENV: ${{ vars.ENVIRONMENT }} volumes: - .:/deployment diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index dec94acf0..710d0642b 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -148,6 +148,7 @@ services: - DATABASE_URL=${AIRFLOW_CONN_PG} # TODO: create dedicated RO creds for api - SECRET_KEY=${API_SECRET_KEY} - ROOT_PATH=/api + - TOKEN_ENABLED=${API_TOKEN_ENABLED} reverse-proxy: image: traefik:v2.10 diff --git a/deployment/main.tf b/deployment/main.tf index 94821f2e7..9cd708788 100644 --- a/deployment/main.tf +++ b/deployment/main.tf @@ -82,6 +82,11 @@ variable "api_version" { type = string } +variable "api_token_enabled" { + description = "Whether to enable the api token auth or not" + type = string +} + variable "ssh_private_key" { description = "The associated public key will be deployed to the instance" type = string @@ -127,6 +132,7 @@ module "stack_data" { public_hostname = var.public_hostname airflow__core__fernet_key = var.airflow__core__fernet_key dora_api_token = var.dora_api_token + api_token_enabled = var.api_token_enabled } output "public_ip" { diff --git a/deployment/modules/stack_data/main.tf b/deployment/modules/stack_data/main.tf index cc9363ab3..bb99ed0c9 100644 --- a/deployment/modules/stack_data/main.tf +++ b/deployment/modules/stack_data/main.tf @@ -141,6 +141,7 @@ resource "null_resource" "up" { SIRENE_STOCK_UNITE_LEGALE_FILE_URL=https://www.data.gouv.fr/fr/datasets/r/825f4199-cadd-486c-ac46-a65a8ea1a047 UN_JEUNE_UNE_SOLUTION_API_URL=https://mes-aides.1jeune1solution.beta.gouv.fr/api/ PUBLIC_HOSTNAME=${var.public_hostname} + API_TOKEN_ENABLED=${var.api_token_enabled} EOT ) destination = "${local.work_dir}/deployment/.env" diff --git a/deployment/modules/stack_data/variables.tf b/deployment/modules/stack_data/variables.tf index 352ec7c2a..88d1220ad 100644 --- a/deployment/modules/stack_data/variables.tf +++ b/deployment/modules/stack_data/variables.tf @@ -104,3 +104,8 @@ variable "dora_api_token" { type = string sensitive = true } + +variable "api_token_enabled" { + description = "Whether to enable the api token auth or not" + type = string +} diff --git a/deployment/template.terraform.tfvars.json b/deployment/template.terraform.tfvars.json index daf8d7175..a24fa63d9 100644 --- a/deployment/template.terraform.tfvars.json +++ b/deployment/template.terraform.tfvars.json @@ -17,5 +17,6 @@ "ssh_private_key": null, "public_hostname": null, "airflow__core__fernet_key": null, - "dora_api_token": null + "dora_api_token": null, + "api_token_enabled": null } \ No newline at end of file