| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** 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: "Dataproc" |
| description: |- |
| Describes an autoscaling policy for Dataproc cluster autoscaler. |
| --- |
| |
| # google_dataproc_autoscaling_policy |
| |
| Describes an autoscaling policy for Dataproc cluster autoscaler. |
| |
| |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=dataproc_autoscaling_policy&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Dataproc Autoscaling Policy |
| |
| |
| ```hcl |
| resource "google_dataproc_cluster" "basic" { |
| name = "dataproc-policy" |
| region = "us-central1" |
| |
| cluster_config { |
| autoscaling_config { |
| policy_uri = google_dataproc_autoscaling_policy.asp.name |
| } |
| } |
| } |
| |
| resource "google_dataproc_autoscaling_policy" "asp" { |
| policy_id = "dataproc-policy" |
| location = "us-central1" |
| |
| worker_config { |
| max_instances = 3 |
| } |
| |
| basic_algorithm { |
| yarn_config { |
| graceful_decommission_timeout = "30s" |
| |
| scale_up_factor = 0.5 |
| scale_down_factor = 0.5 |
| } |
| } |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `policy_id` - |
| (Required) |
| The policy id. The id must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), |
| and hyphens (-). Cannot begin or end with underscore or hyphen. Must consist of between |
| 3 and 50 characters. |
| |
| |
| - - - |
| |
| |
| * `worker_config` - |
| (Optional) |
| Describes how the autoscaler will operate for primary workers. |
| Structure is [documented below](#nested_worker_config). |
| |
| * `secondary_worker_config` - |
| (Optional) |
| Describes how the autoscaler will operate for secondary workers. |
| Structure is [documented below](#nested_secondary_worker_config). |
| |
| * `basic_algorithm` - |
| (Optional) |
| Basic algorithm for autoscaling. |
| Structure is [documented below](#nested_basic_algorithm). |
| |
| * `location` - |
| (Optional) |
| The location where the autoscaling policy should reside. |
| The default value is `global`. |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| |
| <a name="nested_worker_config"></a>The `worker_config` block supports: |
| |
| * `min_instances` - |
| (Optional) |
| Minimum number of instances for this group. Bounds: [2, maxInstances]. Defaults to 2. |
| |
| * `max_instances` - |
| (Required) |
| Maximum number of instances for this group. |
| |
| * `weight` - |
| (Optional) |
| Weight for the instance group, which is used to determine the fraction of total workers |
| in the cluster from this instance group. For example, if primary workers have weight 2, |
| and secondary workers have weight 1, the cluster will have approximately 2 primary workers |
| for each secondary worker. |
| The cluster may not reach the specified balance if constrained by min/max bounds or other |
| autoscaling settings. For example, if maxInstances for secondary workers is 0, then only |
| primary workers will be added. The cluster can also be out of balance when created. |
| If weight is not set on any instance group, the cluster will default to equal weight for |
| all groups: the cluster will attempt to maintain an equal number of workers in each group |
| within the configured size bounds for each group. If weight is set for one group only, |
| the cluster will default to zero weight on the unset group. For example if weight is set |
| only on primary workers, the cluster will use primary workers only and no secondary workers. |
| |
| <a name="nested_secondary_worker_config"></a>The `secondary_worker_config` block supports: |
| |
| * `min_instances` - |
| (Optional) |
| Minimum number of instances for this group. Bounds: [0, maxInstances]. Defaults to 0. |
| |
| * `max_instances` - |
| (Optional) |
| Maximum number of instances for this group. Note that by default, clusters will not use |
| secondary workers. Required for secondary workers if the minimum secondary instances is set. |
| Bounds: [minInstances, ). Defaults to 0. |
| |
| * `weight` - |
| (Optional) |
| Weight for the instance group, which is used to determine the fraction of total workers |
| in the cluster from this instance group. For example, if primary workers have weight 2, |
| and secondary workers have weight 1, the cluster will have approximately 2 primary workers |
| for each secondary worker. |
| The cluster may not reach the specified balance if constrained by min/max bounds or other |
| autoscaling settings. For example, if maxInstances for secondary workers is 0, then only |
| primary workers will be added. The cluster can also be out of balance when created. |
| If weight is not set on any instance group, the cluster will default to equal weight for |
| all groups: the cluster will attempt to maintain an equal number of workers in each group |
| within the configured size bounds for each group. If weight is set for one group only, |
| the cluster will default to zero weight on the unset group. For example if weight is set |
| only on primary workers, the cluster will use primary workers only and no secondary workers. |
| |
| <a name="nested_basic_algorithm"></a>The `basic_algorithm` block supports: |
| |
| * `cooldown_period` - |
| (Optional) |
| Duration between scaling events. A scaling period starts after the |
| update operation from the previous event has completed. |
| Bounds: [2m, 1d]. Default: 2m. |
| |
| * `yarn_config` - |
| (Required) |
| YARN autoscaling configuration. |
| Structure is [documented below](#nested_yarn_config). |
| |
| |
| <a name="nested_yarn_config"></a>The `yarn_config` block supports: |
| |
| * `graceful_decommission_timeout` - |
| (Required) |
| Timeout for YARN graceful decommissioning of Node Managers. Specifies the |
| duration to wait for jobs to complete before forcefully removing workers |
| (and potentially interrupting jobs). Only applicable to downscaling operations. |
| Bounds: [0s, 1d]. |
| |
| * `scale_up_factor` - |
| (Required) |
| Fraction of average pending memory in the last cooldown period for which to |
| add workers. A scale-up factor of 1.0 will result in scaling up so that there |
| is no pending memory remaining after the update (more aggressive scaling). |
| A scale-up factor closer to 0 will result in a smaller magnitude of scaling up |
| (less aggressive scaling). |
| Bounds: [0.0, 1.0]. |
| |
| * `scale_down_factor` - |
| (Required) |
| Fraction of average pending memory in the last cooldown period for which to |
| remove workers. A scale-down factor of 1 will result in scaling down so that there |
| is no available memory remaining after the update (more aggressive scaling). |
| A scale-down factor of 0 disables removing workers, which can be beneficial for |
| autoscaling a single job. |
| Bounds: [0.0, 1.0]. |
| |
| * `scale_up_min_worker_fraction` - |
| (Optional) |
| Minimum scale-up threshold as a fraction of total cluster size before scaling |
| occurs. For example, in a 20-worker cluster, a threshold of 0.1 means the autoscaler |
| must recommend at least a 2-worker scale-up for the cluster to scale. A threshold of |
| 0 means the autoscaler will scale up on any recommended change. |
| Bounds: [0.0, 1.0]. Default: 0.0. |
| |
| * `scale_down_min_worker_fraction` - |
| (Optional) |
| Minimum scale-down threshold as a fraction of total cluster size before scaling occurs. |
| For example, in a 20-worker cluster, a threshold of 0.1 means the autoscaler must |
| recommend at least a 2 worker scale-down for the cluster to scale. A threshold of 0 |
| means the autoscaler will scale down on any recommended change. |
| Bounds: [0.0, 1.0]. Default: 0.0. |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}}` |
| |
| * `name` - |
| The "resource name" of the autoscaling policy. |
| |
| |
| ## 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 |
| |
| |
| AutoscalingPolicy can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}}` |
| * `{{project}}/{{location}}/{{policy_id}}` |
| * `{{location}}/{{policy_id}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import AutoscalingPolicy using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}}" |
| to = google_dataproc_autoscaling_policy.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), AutoscalingPolicy can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_dataproc_autoscaling_policy.default projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}} |
| $ terraform import google_dataproc_autoscaling_policy.default {{project}}/{{location}}/{{policy_id}} |
| $ terraform import google_dataproc_autoscaling_policy.default {{location}}/{{policy_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). |