github.com/jmbataller/terraform@v0.6.8-0.20151125192640-b7a12e3a580c/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 ``` 24 resource "google_compute_instance_template" "foobar" { 25 name = "foobar" 26 machine_type = "n1-standard-1" 27 can_ip_forward = false 28 tags = ["foo", "bar"] 29 30 disk { 31 source_image = "debian-cloud/debian-7-wheezy-v20140814" 32 } 33 34 network_interface { 35 network = "default" 36 } 37 38 metadata { 39 foo = "bar" 40 } 41 42 service_account { 43 scopes = ["userinfo-email", "compute-ro", "storage-ro"] 44 } 45 } 46 47 resource "google_compute_target_pool" "foobar" { 48 name = "foobar" 49 } 50 51 resource "google_compute_instance_group_manager" "foobar" { 52 name = "foobar" 53 instance_template = "${google_compute_instance_template.foobar.self_link}" 54 target_pools = ["${google_compute_target_pool.foobar.self_link}"] 55 base_instance_name = "foobar" 56 zone = "us-central1-f" 57 } 58 59 resource "google_compute_autoscaler" "foobar" { 60 name = "foobar" 61 zone = "us-central1-f" 62 target = "${google_compute_instance_group_manager.foobar.self_link}" 63 autoscaling_policy = { 64 max_replicas = 5 65 min_replicas = 1 66 cooldown_period = 60 67 cpu_utilization = { 68 target = 0.5 69 } 70 } 71 } 72 ``` 73 74 ## Argument Reference 75 76 The following arguments are supported: 77 78 * `description` - (Optional) An optional textual description of the instance 79 group manager. 80 81 * `target` - (Required) The full URL to the instance group manager whose size we 82 control. 83 84 * `autoscaling_policy.` - (Required) The parameters of the autoscaling 85 algorithm. Structure is documented below. 86 87 * `zone` - (Required) The zone of the target. 88 89 The `autoscaling_policy` block contains: 90 91 * `max_replicas` - (Required) The group will never be larger than this. 92 93 * `min_replicas` - (Required) The group will never be smaller than this. 94 95 * `cooldown_period` - (Optional) Period to wait between changes. This should be 96 at least double the time your instances take to start up. 97 98 * `cpu_utilization` - (Optional) A policy that scales when the cluster's average 99 CPU is above or below a given threshold. Structure is documented below. 100 101 * `metric` - (Optional) A policy that scales according to Google Cloud 102 Monitoring metrics Structure is documented below. 103 104 * `load_balancing_utilization` - (Optional) A policy that scales when the load 105 reaches a proportion of a limit defined in the HTTP load balancer. Structure 106 is documented below. 107 108 The `cpu_utilization` block contains: 109 110 * `target` - The floating point threshold where CPU utilization should be. E.g. 111 for 50% one would specify 0.5. 112 113 The `metric` block contains (more documentation 114 [here](https://cloud.google.com/monitoring/api/metrics)): 115 116 * `name` - The name of the Google Cloud Monitoring metric to follow, e.g. 117 compute.googleapis.com/instance/network/received_bytes_count 118 119 * `type` - Either "cumulative", "delta", or "gauge". 120 121 * `target` - The desired metric value per instance. Must be a positive value. 122 123 The `load_balancing_utilization` block contains: 124 125 * `target` - The floating point threshold where load balancing utilization 126 should be. E.g. if the load balancer's `maxRatePerInstance` is 10 requests 127 per second (RPS) then setting this to 0.5 would cause the group to be scaled 128 such that each instance receives 5 RPS. 129 130 131 ## Attributes Reference 132 133 The following attributes are exported: 134 135 * `self_link` - The URL of the created resource.