github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/google/r/compute_autoscaler.html.markdown (about)

     1  ---
     2  layout: "google"
     3  page_title: "Google: google_compute_autoscaler"
     4  sidebar_current: "docs-google-compute-autoscaler"
     5  description: |-
     6    Manages an Autoscaler within GCE.
     7  ---
     8  
     9  # google\_compute\_autoscaler
    10  
    11  A Compute Engine Autoscaler automatically adds or removes virtual machines from
    12  a managed instance group based on increases or decreases in load. This allows
    13  your applications to gracefully handle increases in traffic and reduces cost
    14  when the need for resources is lower. You just define the autoscaling policy and
    15  the autoscaler performs automatic scaling based on the measured load. For more
    16  information, see [the official
    17  documentation](https://cloud.google.com/compute/docs/autoscaler/) and
    18  [API](https://cloud.google.com/compute/docs/autoscaler/v1beta2/autoscalers)
    19  
    20  
    21  ## Example Usage
    22  
    23  ```hcl
    24  resource "google_compute_instance_template" "foobar" {
    25    name           = "foobar"
    26    machine_type   = "n1-standard-1"
    27    can_ip_forward = false
    28  
    29    tags = ["foo", "bar"]
    30  
    31    disk {
    32      source_image = "debian-cloud/debian-8"
    33    }
    34  
    35    network_interface {
    36      network = "default"
    37    }
    38  
    39    metadata {
    40      foo = "bar"
    41    }
    42  
    43    service_account {
    44      scopes = ["userinfo-email", "compute-ro", "storage-ro"]
    45    }
    46  }
    47  
    48  resource "google_compute_target_pool" "foobar" {
    49    name = "foobar"
    50  }
    51  
    52  resource "google_compute_instance_group_manager" "foobar" {
    53    name = "foobar"
    54    zone = "us-central1-f"
    55  
    56    instance_template  = "${google_compute_instance_template.foobar.self_link}"
    57    target_pools       = ["${google_compute_target_pool.foobar.self_link}"]
    58    base_instance_name = "foobar"
    59  }
    60  
    61  resource "google_compute_autoscaler" "foobar" {
    62    name   = "foobar"
    63    zone   = "us-central1-f"
    64    target = "${google_compute_instance_group_manager.foobar.self_link}"
    65  
    66    autoscaling_policy = {
    67      max_replicas    = 5
    68      min_replicas    = 1
    69      cooldown_period = 60
    70  
    71      cpu_utilization {
    72        target = 0.5
    73      }
    74    }
    75  }
    76  ```
    77  
    78  ## Argument Reference
    79  
    80  The following arguments are supported:
    81  
    82  * `name` - (Required) The name of the autoscaler.
    83  
    84  * `target` - (Required) The full URL to the instance group manager whose size we
    85    control.
    86  
    87  * `zone` - (Required) The zone of the target.
    88  
    89  * `autoscaling_policy.` - (Required) The parameters of the autoscaling
    90    algorithm. Structure is documented below.
    91  
    92  - - -
    93  
    94  * `description` - (Optional) An optional textual description of the instance
    95      group manager.
    96  
    97  * `project` - (Optional) The project in which the resource belongs. If it
    98      is not provided, the provider project is used.
    99  
   100  The `autoscaling_policy` block contains:
   101  
   102  * `max_replicas` - (Required) The group will never be larger than this.
   103  
   104  * `min_replicas` - (Required) The group will never be smaller than this.
   105  
   106  * `cooldown_period` - (Optional) Period to wait between changes. This should be
   107    at least double the time your instances take to start up.
   108  
   109  * `cpu_utilization` - (Optional) A policy that scales when the cluster's average
   110    CPU is above or below a given threshold. Structure is documented below.
   111  
   112  * `metric` - (Optional) A policy that scales according to Google Cloud
   113    Monitoring metrics  Structure is documented below.
   114  
   115  * `load_balancing_utilization` - (Optional) A policy that scales when the load
   116    reaches a proportion of a limit defined in the HTTP load balancer. Structure
   117  is documented below.
   118  
   119  The `cpu_utilization` block contains:
   120  
   121  * `target` - The floating point threshold where CPU utilization should be. E.g.
   122    for 50% one would specify 0.5.
   123  
   124  The `metric` block contains (more documentation
   125  [here](https://cloud.google.com/monitoring/api/metrics)):
   126  
   127  * `name` - The name of the Google Cloud Monitoring metric to follow, e.g.
   128    `compute.googleapis.com/instance/network/received_bytes_count`
   129  
   130  * `type` - Either "cumulative", "delta", or "gauge".
   131  
   132  * `target` - The desired metric value per instance. Must be a positive value.
   133  
   134  The `load_balancing_utilization` block contains:
   135  
   136  * `target` - The floating point threshold where load balancing utilization
   137    should be. E.g. if the load balancer's `maxRatePerInstance` is 10 requests
   138    per second (RPS) then setting this to 0.5 would cause the group to be scaled
   139    such that each instance receives 5 RPS.
   140  
   141  
   142  ## Attributes Reference
   143  
   144  In addition to the arguments listed above, the following computed attributes are
   145  exported:
   146  
   147  * `self_link` - The URL of the created resource.