| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "App Engine" |
| description: |- |
| Standard App Version resource to create a new version of standard GAE Application. |
| --- |
| |
| # google\_app\_engine\_standard\_app\_version |
| |
| Standard App Version resource to create a new version of standard GAE Application. |
| Learn about the differences between the standard environment and the flexible environment |
| at https://cloud.google.com/appengine/docs/the-appengine-environments. |
| Currently supporting Zip and File Containers. |
| |
| |
| To get more information about StandardAppVersion, see: |
| |
| * [API documentation](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/appengine/docs/standard) |
| |
| ## Example Usage - App Engine Standard App Version |
| |
| |
| ```hcl |
| resource "google_service_account" "custom_service_account" { |
| account_id = "my-account" |
| display_name = "Custom Service Account" |
| } |
| |
| resource "google_project_iam_member" "gae_api" { |
| project = google_service_account.custom_service_account.project |
| role = "roles/compute.networkUser" |
| member = "serviceAccount:${google_service_account.custom_service_account.email}" |
| } |
| |
| resource "google_project_iam_member" "storage_viewer" { |
| project = google_service_account.custom_service_account.project |
| role = "roles/storage.objectViewer" |
| member = "serviceAccount:${google_service_account.custom_service_account.email}" |
| } |
| |
| resource "google_app_engine_standard_app_version" "myapp_v1" { |
| version_id = "v1" |
| service = "myapp" |
| runtime = "nodejs10" |
| |
| entrypoint { |
| shell = "node ./app.js" |
| } |
| |
| deployment { |
| zip { |
| source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}" |
| } |
| } |
| |
| env_variables = { |
| port = "8080" |
| } |
| |
| automatic_scaling { |
| max_concurrent_requests = 10 |
| min_idle_instances = 1 |
| max_idle_instances = 3 |
| min_pending_latency = "1s" |
| max_pending_latency = "5s" |
| standard_scheduler_settings { |
| target_cpu_utilization = 0.5 |
| target_throughput_utilization = 0.75 |
| min_instances = 2 |
| max_instances = 10 |
| } |
| } |
| |
| delete_service_on_destroy = true |
| service_account = google_service_account.custom_service_account.email |
| } |
| |
| resource "google_app_engine_standard_app_version" "myapp_v2" { |
| version_id = "v2" |
| service = "myapp" |
| runtime = "nodejs10" |
| app_engine_apis = true |
| |
| entrypoint { |
| shell = "node ./app.js" |
| } |
| |
| deployment { |
| zip { |
| source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}" |
| } |
| } |
| |
| env_variables = { |
| port = "8080" |
| } |
| |
| basic_scaling { |
| max_instances = 5 |
| } |
| |
| noop_on_destroy = true |
| service_account = google_service_account.custom_service_account.email |
| } |
| |
| resource "google_storage_bucket" "bucket" { |
| 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: |
| |
| |
| * `runtime` - |
| (Required) |
| Desired runtime. Example python27. |
| |
| * `deployment` - |
| (Required) |
| Code and application artifacts that make up this version. |
| Structure is [documented below](#nested_deployment). |
| |
| * `entrypoint` - |
| (Required) |
| The entrypoint for the application. |
| Structure is [documented below](#nested_entrypoint). |
| |
| * `service` - |
| (Required) |
| AppEngine service resource |
| |
| |
| <a name="nested_deployment"></a>The `deployment` block supports: |
| |
| * `zip` - |
| (Optional) |
| Zip File |
| Structure is [documented below](#nested_zip). |
| |
| * `files` - |
| (Optional) |
| Manifest of the files stored in Google Cloud Storage that are included as part of this version. |
| All files must be readable using the credentials supplied with this call. |
| Structure is [documented below](#nested_files). |
| |
| |
| <a name="nested_zip"></a>The `zip` block supports: |
| |
| * `source_url` - |
| (Required) |
| Source URL |
| |
| * `files_count` - |
| (Optional) |
| files count |
| |
| <a name="nested_files"></a>The `files` block supports: |
| |
| * `name` - (Required) The identifier for this object. Format specified above. |
| |
| * `sha1_sum` - |
| (Optional) |
| SHA1 checksum of the file |
| |
| * `source_url` - |
| (Required) |
| Source URL |
| |
| <a name="nested_entrypoint"></a>The `entrypoint` block supports: |
| |
| * `shell` - |
| (Required) |
| The format should be a shell command that can be fed to bash -c. |
| |
| - - - |
| |
| |
| * `version_id` - |
| (Optional) |
| Relative name of the version within the service. For example, `v1`. Version names can contain only lowercase letters, numbers, or hyphens. Reserved names,"default", "latest", and any name with the prefix "ah-". |
| |
| * `service_account` - |
| (Optional) |
| The identity that the deployed version will run as. Admin API will use the App Engine Appspot service account as default if this field is neither provided in app.yaml file nor through CLI flag. |
| |
| * `threadsafe` - |
| (Optional) |
| Whether multiple requests can be dispatched to this version at once. |
| |
| * `app_engine_apis` - |
| (Optional) |
| Allows App Engine second generation runtimes to access the legacy bundled services. |
| |
| * `runtime_api_version` - |
| (Optional) |
| The version of the API in the given runtime environment. |
| Please see the app.yaml reference for valid values at `https://cloud.google.com/appengine/docs/standard/<language>/config/appref`\ |
| Substitute `<language>` with `python`, `java`, `php`, `ruby`, `go` or `nodejs`. |
| |
| * `handlers` - |
| (Optional) |
| An ordered list of URL-matching patterns that should be applied to incoming requests. |
| The first matching URL handles the request and other request handlers are not attempted. |
| Structure is [documented below](#nested_handlers). |
| |
| * `libraries` - |
| (Optional) |
| Configuration for third-party Python runtime libraries that are required by the application. |
| Structure is [documented below](#nested_libraries). |
| |
| * `env_variables` - |
| (Optional) |
| Environment variables available to the application. |
| |
| * `vpc_access_connector` - |
| (Optional) |
| Enables VPC connectivity for standard apps. |
| Structure is [documented below](#nested_vpc_access_connector). |
| |
| * `inbound_services` - |
| (Optional) |
| A list of the types of messages that this application is able to receive. |
| Each value may be one of: `INBOUND_SERVICE_MAIL`, `INBOUND_SERVICE_MAIL_BOUNCE`, `INBOUND_SERVICE_XMPP_ERROR`, `INBOUND_SERVICE_XMPP_MESSAGE`, `INBOUND_SERVICE_XMPP_SUBSCRIBE`, `INBOUND_SERVICE_XMPP_PRESENCE`, `INBOUND_SERVICE_CHANNEL_PRESENCE`, `INBOUND_SERVICE_WARMUP`. |
| |
| * `instance_class` - |
| (Optional) |
| Instance class that is used to run this version. Valid values are |
| AutomaticScaling: F1, F2, F4, F4_1G |
| BasicScaling or ManualScaling: B1, B2, B4, B4_1G, B8 |
| Defaults to F1 for AutomaticScaling and B2 for ManualScaling and BasicScaling. If no scaling is specified, AutomaticScaling is chosen. |
| |
| * `automatic_scaling` - |
| (Optional) |
| Automatic scaling is based on request rate, response latencies, and other application metrics. |
| Structure is [documented below](#nested_automatic_scaling). |
| |
| * `basic_scaling` - |
| (Optional) |
| Basic scaling creates instances when your application receives requests. Each instance will be shut down when the application becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. |
| Structure is [documented below](#nested_basic_scaling). |
| |
| * `manual_scaling` - |
| (Optional) |
| A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. |
| Structure is [documented below](#nested_manual_scaling). |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| * `noop_on_destroy` - (Optional) If set to `true`, the application version will not be deleted. |
| |
| * `delete_service_on_destroy` - (Optional) If set to `true`, the service will be deleted if it is the last version. |
| |
| |
| <a name="nested_handlers"></a>The `handlers` block supports: |
| |
| * `url_regex` - |
| (Optional) |
| URL prefix. Uses regular expression syntax, which means regexp special characters must be escaped, but should not contain groupings. |
| All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path. |
| |
| * `security_level` - |
| (Optional) |
| Security (HTTPS) enforcement for this URL. |
| Possible values are: `SECURE_DEFAULT`, `SECURE_NEVER`, `SECURE_OPTIONAL`, `SECURE_ALWAYS`. |
| |
| * `login` - |
| (Optional) |
| Methods to restrict access to a URL based on login status. |
| Possible values are: `LOGIN_OPTIONAL`, `LOGIN_ADMIN`, `LOGIN_REQUIRED`. |
| |
| * `auth_fail_action` - |
| (Optional) |
| Actions to take when the user is not logged in. |
| Possible values are: `AUTH_FAIL_ACTION_REDIRECT`, `AUTH_FAIL_ACTION_UNAUTHORIZED`. |
| |
| * `redirect_http_response_code` - |
| (Optional) |
| 30x code to use when performing redirects for the secure field. |
| Possible values are: `REDIRECT_HTTP_RESPONSE_CODE_301`, `REDIRECT_HTTP_RESPONSE_CODE_302`, `REDIRECT_HTTP_RESPONSE_CODE_303`, `REDIRECT_HTTP_RESPONSE_CODE_307`. |
| |
| * `script` - |
| (Optional) |
| Executes a script to handle the requests that match this URL pattern. |
| Only the auto value is supported for Node.js in the App Engine standard environment, for example "script:" "auto". |
| Structure is [documented below](#nested_script). |
| |
| * `static_files` - |
| (Optional) |
| Files served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files. Static file handlers describe which files in the application directory are static files, and which URLs serve them. |
| Structure is [documented below](#nested_static_files). |
| |
| |
| <a name="nested_script"></a>The `script` block supports: |
| |
| * `script_path` - |
| (Required) |
| Path to the script from the application root directory. |
| |
| <a name="nested_static_files"></a>The `static_files` block supports: |
| |
| * `path` - |
| (Optional) |
| Path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern. |
| |
| * `upload_path_regex` - |
| (Optional) |
| Regular expression that matches the file paths for all files that should be referenced by this handler. |
| |
| * `http_headers` - |
| (Optional) |
| HTTP headers to use for all responses from these URLs. |
| An object containing a list of "key:value" value pairs.". |
| |
| * `mime_type` - |
| (Optional) |
| MIME type used to serve all files served by this handler. |
| Defaults to file-specific MIME types, which are derived from each file's filename extension. |
| |
| * `expiration` - |
| (Optional) |
| Time a static file served by this handler should be cached by web proxies and browsers. |
| A duration in seconds with up to nine fractional digits, terminated by 's'. Example "3.5s". |
| |
| * `require_matching_file` - |
| (Optional) |
| Whether this handler should match the request if the file referenced by the handler does not exist. |
| |
| * `application_readable` - |
| (Optional) |
| Whether files should also be uploaded as code data. By default, files declared in static file handlers are uploaded as |
| static data and are only served to end users; they cannot be read by the application. If enabled, uploads are charged |
| against both your code and static data storage resource quotas. |
| |
| <a name="nested_libraries"></a>The `libraries` block supports: |
| |
| * `name` - |
| (Optional) |
| Name of the library. Example "django". |
| |
| * `version` - |
| (Optional) |
| Version of the library to select, or "latest". |
| |
| <a name="nested_vpc_access_connector"></a>The `vpc_access_connector` block supports: |
| |
| * `name` - |
| (Required) |
| Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1. |
| |
| * `egress_setting` - |
| (Optional) |
| The egress setting for the connector, controlling what traffic is diverted through it. |
| |
| <a name="nested_automatic_scaling"></a>The `automatic_scaling` block supports: |
| |
| * `max_concurrent_requests` - |
| (Optional) |
| Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. |
| Defaults to a runtime-specific value. |
| |
| * `max_idle_instances` - |
| (Optional) |
| Maximum number of idle instances that should be maintained for this version. |
| |
| * `max_pending_latency` - |
| (Optional) |
| Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it. |
| A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". |
| |
| * `min_idle_instances` - |
| (Optional) |
| Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a service. |
| |
| * `min_pending_latency` - |
| (Optional) |
| Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it. |
| A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". |
| |
| * `standard_scheduler_settings` - |
| (Optional) |
| Scheduler settings for standard environment. |
| Structure is [documented below](#nested_standard_scheduler_settings). |
| |
| |
| <a name="nested_standard_scheduler_settings"></a>The `standard_scheduler_settings` block supports: |
| |
| * `target_cpu_utilization` - |
| (Optional) |
| Target CPU utilization ratio to maintain when scaling. Should be a value in the range [0.50, 0.95], zero, or a negative value. |
| |
| * `target_throughput_utilization` - |
| (Optional) |
| Target throughput utilization ratio to maintain when scaling. Should be a value in the range [0.50, 0.95], zero, or a negative value. |
| |
| * `min_instances` - |
| (Optional) |
| Minimum number of instances to run for this version. Set to zero to disable minInstances configuration. |
| |
| * `max_instances` - |
| (Optional) |
| Maximum number of instances to run for this version. Set to zero to disable maxInstances configuration. |
| |
| <a name="nested_basic_scaling"></a>The `basic_scaling` block supports: |
| |
| * `idle_timeout` - |
| (Optional) |
| Duration of time after the last request that an instance must wait before the instance is shut down. |
| A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". Defaults to 900s. |
| |
| * `max_instances` - |
| (Required) |
| Maximum number of instances to create for this version. Must be in the range [1.0, 200.0]. |
| |
| <a name="nested_manual_scaling"></a>The `manual_scaling` block supports: |
| |
| * `instances` - |
| (Required) |
| Number of instances to assign to the service at the start. |
| **Note:** When managing the number of instances at runtime through the App Engine Admin API or the (now deprecated) Python 2 |
| Modules API set_num_instances() you must use `lifecycle.ignore_changes = ["manual_scaling"[0].instances]` to prevent drift detection. |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `apps/{{project}}/services/{{service}}/versions/{{version_id}}` |
| |
| * `name` - |
| Full path to the Version resource in the API. Example, "v1". |
| |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| StandardAppVersion can be imported using any of these accepted formats: |
| |
| * `apps/{{project}}/services/{{service}}/versions/{{version_id}}` |
| * `{{project}}/{{service}}/{{version_id}}` |
| * `{{service}}/{{version_id}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import StandardAppVersion using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "apps/{{project}}/services/{{service}}/versions/{{version_id}}" |
| to = google_app_engine_standard_app_version.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), StandardAppVersion can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_app_engine_standard_app_version.default apps/{{project}}/services/{{service}}/versions/{{version_id}} |
| $ terraform import google_app_engine_standard_app_version.default {{project}}/{{service}}/{{version_id}} |
| $ terraform import google_app_engine_standard_app_version.default {{service}}/{{version_id}} |
| ``` |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |