handlers not working as expected in standard app engine application deployed with terraform

50 views Asked by At

I'm a beginner in App engine and terraform and I'm currently trying to deploy a standard PHP application in app engine using terraform with a GitLab CI pipeline, the app worked fine when deploying it with app.yaml and handler.php file but when switching to terraform I have an issue with my handlers that serve static files, it seems that these are totally ignored, and I can't figure out which part of the handler is wrong.

The part that handles my application configuration in the main.tf file:

resource "google_app_engine_standard_app_version" "myapp_v1" {
  version_id      = "20231121t143729"
  service         = "default"
  runtime         = "php82"
  app_engine_apis = true
  entrypoint {
    shell = "serve handler.php"
    }

  deployment {
    zip { //"https://storage.googleapis.com/ofr-bdf-sup-gcp-dev.appspot.com/application" 
      source_url = "https://storage.googleapis.com/${google_storage_bucket.app.name}/${google_storage_bucket_object.app.name}"
    }
    }

  /*handlers {
    url_regex = "/css/.*"
    static_files {
      application_readable = false
      path              = "./src/css"
      upload_path_regex = "css/.*"
    }
  }*/
  handlers {
  url_regex = "/css/.*"
  //"/css/"
  static_files {
    path  = "/src/css"
    //"/src/css/"
    upload_path_regex = "src/css/(.*)"
    //"src/css/(.*)"
  }
}

  handlers {
    url_regex = "/images"
    static_files {
      path              = "/src/images"
      upload_path_regex = "images/(.*)"
    }
  }

  handlers {
    url_regex = "/js"
    static_files {
      path              = "/src/js"
      upload_path_regex = "js/(.*)"
    }
  }
 handlers {
    /*url_regex = "/.*"  
    script {
      script_path = "auto" */

    url_regex = "/.*"  
    script {
      script_path = "handler.php"  # Utilisation de handler.php pour gérer ces routes
    }
  }

  env_variables = {
    port = "8080"
  }

  basic_scaling {
    max_instances = 5
  }

  noop_on_destroy = true
  service_account = google_service_account.custom_service_account.email
}

my project structure:

enter image description here

the console of my browser after the deployment of the app: enter image description here

I tried changing the 'url_regex' attribute, but it seems that terraform has its own regex rules.

0

There are 0 answers