hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.32k stars 1.73k forks source link

Unable to deploy flexible app-engine with python version 3.7 using terraform #17006

Open pedrosdf opened 9 months ago

pedrosdf commented 9 months ago

Community Note

Description

User is unable to deploy a new Google App-engine flexible instance with python version 3.7 using terraform and gets /readiness_check failReason:"null" error.

Affected Resource(s)

google_app_engine_flexible_app_version

Terraform Configuration Files

resource "google_app_engine_flexible_app_version" "app-engine-service-flexible" {

version_id = "v2"

project = var.project_id

runtime = "python"

service = "hello-world"

entrypoint {

shell = "gunicorn -b :$PORT main:app"

}

deployment {

zip {

source_url =
"https://storage.googleapis.com/app-engine-nonprod-bucket/hello_world.zip"

}

cloud_build_options {

app_yaml_path = "./hello_world/app.yaml"

}

}

automatic_scaling {

cool_down_period = "120s"

cpu_utilization {

target_utilization = 0.5

}

min_total_instances = 1

max_total_instances = 1

}

liveness_check {

path = "/"

}

readiness_check {

path = "/"

app_start_timeout = "3600s"

}
}

Additional information

this is the app.yaml file: App Engine Module/Version:

Include app.yaml:

included_files:

runtime_config:

python_version: 3.7

runtime: python

env: flex

entrypoint: 'pwd && ls && python -m pip install -r ./hello_world/requirements.txt && gunicorn -b :$PORT main:app'

b/320650947

edwardmedia commented 9 months ago

@pedrosdf can you share the debug log for your tf apply?

oaa97181 commented 9 months ago

@edwardmedia Actual app.yaml taken from here:


# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  operating_system: ubuntu22

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

Terraform version: terraform -v Terraform v1.6.5 on darwin_arm64

debug log: clean debug.log

â•·
│ Error: Error waiting to create FlexibleAppVersion: Error waiting for Creating FlexibleAppVersion: Error code 9, message: An internal error occurred while processing task /app-engine-flex/flex_await_healthy/flex_await_healthy>2024-01-15T23:48:44.284Z210369.jc.0: /bin/sh: 1: exec: gunicorn: not found
│ 
│ 
│   with google_app_engine_flexible_app_version.app-engine-service-flexible,
│   on app_engine.tf line 32, in resource "google_app_engine_flexible_app_version" "app-engine-service-flexible":
│   32: resource "google_app_engine_flexible_app_version" "app-engine-service-flexible" {
│ 
╵
edwardmedia commented 9 months ago

@oaa97181 it appears the api does not take your config. Are you able to deploy the app with gcloud?

An internal error occurred while processing task /app-engine-flex/flex_await_healthy/flex_await_health
oaa97181 commented 9 months ago

@edwardmedia yes, with gcloud app deploy

edwardmedia commented 9 months ago

@oaa97181 can you share the gcloud command that deploys the app? and share its debug log (appending --log-http in the command) as well.

To be clear, when you deployed the app via Terraform config, it works for python v3.6, but not for v3.7? Assuming everything else remains unchanged?

Below is the content of requirements.txt you provided by the link. What versions were they in your cases? Besides, where did you specify the py version?

Flask==3.0.0; python_version > '3.6'
Flask==2.3.3; python_version < '3.7'
Werkzeug==3.0.1; python_version > '3.6'
Werkzeug==2.3.7; python_version < '3.7'
gunicorn==20.1.0
oaa97181 commented 9 months ago

@edwardmedia attaching the log file gloud deploy log.txt

it did not deploy when trying with terraforms google_app_engine_flexible_app_version.