google_app_engine_flexible_app_version

Flexible App Version resource to create a new version of flexible GAE Application. Based on Google Compute Engine, the App Engine flexible environment automatically scales your app up and down while also balancing the load. Learn about the differences between the standard environment and the flexible environment at https://cloud.google.com/appengine/docs/the-appengine-environments.

To get more information about FlexibleAppVersion, see:

Example Usage - App Engine Flexible App Version

resource "google_project" "my_project" {
  name = "appeng-flex"
  project_id = "appeng-flex"
  org_id = "123456789"
  billing_account = "000000-0000000-0000000-000000"
}

resource "google_app_engine_application" "app" {
  project     = google_project.my_project.project_id
  location_id = "us-central"
}

resource "google_project_service" "service" {
  project = google_project.my_project.project_id
  service = "appengineflex.googleapis.com"

  disable_dependent_services = false
}

resource "google_service_account" "custom_service_account" {
  project      = google_project_service.service.project
  account_id   = "my-account"
  display_name = "Custom Service Account"
}

resource "google_project_iam_member" "gae_api" {
  project = google_project_service.service.project
  role    = "roles/compute.networkUser"
  member  = "serviceAccount:${google_service_account.custom_service_account.email}"
}

resource "google_project_iam_member" "logs_writer" {
  project = google_project_service.service.project
  role    = "roles/logging.logWriter"
  member  = "serviceAccount:${google_service_account.custom_service_account.email}"
}

resource "google_project_iam_member" "storage_viewer" {
  project = google_project_service.service.project
  role    = "roles/storage.objectViewer"
  member  = "serviceAccount:${google_service_account.custom_service_account.email}"
}

resource "google_app_engine_flexible_app_version" "myapp_v1" {
  version_id = "v1"
  project    = google_project_iam_member.gae_api.project
  service    = "default"
  runtime    = "nodejs"

  entrypoint {
    shell = "node ./app.js"
  }

  deployment {
    zip {
      source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}"
    }
  }

  liveness_check {
    path = "/"
  }

  readiness_check {
    path = "/"
  }

  env_variables = {
    port = "8080"
  }

  handlers {
    url_regex        = ".*\\/my-path\\/*"
    security_level   = "SECURE_ALWAYS"
    login            = "LOGIN_REQUIRED"
    auth_fail_action = "AUTH_FAIL_ACTION_REDIRECT"

    static_files {
      path = "my-other-path"
      upload_path_regex = ".*\\/my-path\\/*"
    }
  }

  automatic_scaling {
    cool_down_period = "120s"
    cpu_utilization {
      target_utilization = 0.5
    }
  }

  noop_on_destroy = true
  service_account = google_service_account.custom_service_account.email
}

resource "google_storage_bucket" "bucket" {
  project  = google_project.my_project.project_id
  name     = "appengine-static-content"
  location = "US"
}

resource "google_storage_bucket_object" "object" {
  name   = "hello-world.zip"
  bucket = google_storage_bucket.bucket.name
  source = "./test-fixtures/hello-world.zip"
}

Argument Reference

The following arguments are supported:

The readiness_check block supports:

The liveness_check block supports:


The network block supports:

The resources block supports:

The volumes block supports:

The handlers block supports:

The script block supports:

The static_files block supports:

The api_config block supports:

The deployment block supports:

The zip block supports:

The files block supports:

The container block supports:

The cloud_build_options block supports:

The endpoints_api_service block supports:

The entrypoint block supports:

The vpc_access_connector block supports:

The automatic_scaling block supports:

The cpu_utilization block supports:

The request_utilization block supports:

The disk_utilization block supports:

The network_utilization block supports:

The manual_scaling block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

FlexibleAppVersion can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import FlexibleAppVersion using one of the formats above. For example:

import {
  id = "apps/{{project}}/services/{{service}}/versions/{{version_id}}"
  to = google_app_engine_flexible_app_version.default
}

When using the terraform import command, FlexibleAppVersion can be imported using one of the formats above. For example:

$ terraform import google_app_engine_flexible_app_version.default apps/{{project}}/services/{{service}}/versions/{{version_id}}
$ terraform import google_app_engine_flexible_app_version.default {{project}}/{{service}}/{{version_id}}
$ terraform import google_app_engine_flexible_app_version.default {{service}}/{{version_id}}

User Project Overrides

This resource supports User Project Overrides.