diff --git a/r/autoscaler.html.markdown b/r/autoscaler.html.markdown new file mode 100644 index 00000000..63f1753d --- /dev/null +++ b/r/autoscaler.html.markdown @@ -0,0 +1,138 @@ +--- +layout: "google" +page_title: "Google: google_autoscaler" +sidebar_current: "docs-google-resource-autoscaler" +description: |- + Managers an Instance Group within GCE. +--- + +# google\_autoscaler + +**Note**: This resource is in +[beta](https://cloud.google.com/terms/launch-stages). + +A Compute Engine Autoscaler automatically adds or removes virtual machines from +a managed instance group based on increases or decreases in load. This allows +your applications to gracefully handle increases in traffic and reduces cost +when the need for resources is lower. You just define the autoscaling policy and +the autoscaler performs automatic scaling based on the measured load. For more +information, see [the official +documentation](https://cloud.google.com/compute/docs/autoscaler/) and +[API](https://cloud.google.com/compute/docs/autoscaler/v1beta2/autoscalers) + + +## Example Usage + +``` +resource "google_compute_instance_template" "foobar" { + name = "foobar" + machine_type = "n1-standard-1" + can_ip_forward = false + tags = ["foo", "bar"] + + disk { + source_image = "debian-cloud/debian-7-wheezy-v20140814" + } + + network_interface { + network = "default" + } + + metadata { + foo = "bar" + } + + service_account { + scopes = ["userinfo-email", "compute-ro", "storage-ro"] + } +} + +resource "google_compute_target_pool" "foobar" { + name = "foobar" +} + +resource "google_replicapool_instance_group_manager" "foobar" { + name = "foobar" + instance_template = "${google_compute_instance_template.foobar.self_link}" + target_pools = ["${google_compute_target_pool.foobar.self_link}"] + base_instance_name = "foobar" + zone = "us-central1-f" +} + +resource "google_autoscaler" "foobar" { + name = "foobar" + zone = "us-central1-f" + target = "${google_replicapool_instance_group_manager.foobar.self_link}" + autoscaling_policy = { + max_replicas = 5 + min_replicas = 1 + cooldown_period = 60 + cpu_utilization = { + target = 0.5 + } + } +} +``` + +## Argument Refernce + +The following arguments are supported: + +* `description` - (Optional) An optional textual description of the instance +group manager. + +* `target` - (Required) The full URL to the instance group manager whose size we + control. + +* `autoscaling_policy.` - (Required) The parameters of the autoscaling + algorithm. Structure is documented below. + +* `zone` - (Required) The zone of the target. + +The `autoscaling_policy` block contains: + +* `max_replicas` - (Required) The group will never be larger than this. + +* `min_replicas` - (Required) The group will never be smaller than this. + +* `cooldown_period` - (Optional) Period to wait between changes. This should be + at least double the time your instances take to start up. + +* `cpu_utilization` - (Optional) A policy that scales when the cluster's average + CPU is above or below a given threshold. Structure is documented below. + +* `metric` - (Optional) A policy that scales according to Google Cloud + Monitoring metrics Structure is documented below. + +* `load_balancing_utilization` - (Optional) A policy that scales when the load + reaches a proportion of a limit defined in the HTTP load balancer. Structure +is documented below. + +The `cpu_utilization` block contains: + +* `target` - The floating point threshold where CPU utilization should be. E.g. + for 50% one would specify 0.5. + +The `metric` block contains (more documentation +[here](https://cloud.google.com/monitoring/api/metrics)): + +* `name` - The name of the Google Cloud Monitoring metric to follow, e.g. + compute.googleapis.com/instance/network/received_bytes_count + +* `type` - Either "cumulative", "delta", or "gauge". + +* `target` - The desired metric value per instance. Must be a positive value. + +The `load_balancing_utilization` block contains: + +* `target` - The floating point threshold where load balancing utilization + should be. E.g. if the load balancer's `maxRatePerInstance` is 10 requests + per second (RPS) then setting this to 0.5 would cause the group to be scaled + such that each instance receives 5 RPS. + + +## Attributes Reference + +The following attributes are exported: + +* `self_link` - The URL of the created resource. diff --git a/r/replicapool_instance_group_manager.html.markdown b/r/replicapool_instance_group_manager.html.markdown new file mode 100644 index 00000000..d4232b25 --- /dev/null +++ b/r/replicapool_instance_group_manager.html.markdown @@ -0,0 +1,68 @@ +--- +layout: "google" +page_title: "Google: google_replicapool_instance_group_manager" +sidebar_current: "docs-google-resource-instance_group_manager" +description: |- + Manages an Instance Group within GCE. +--- + +# google\_replicapool\_instance\_group\_manager + +**Note**: This resource is in +[beta](https://cloud.google.com/terms/launch-stages). + +The Google Compute Engine Instance Group Manager API creates and manages pools +of homogeneous Compute Engine virtual machine instances from a common instance +template. For more information, see [the official documentation](https://cloud.google.com/compute/docs/instance-groups/manager +and [API](https://cloud.google.com/compute/docs/instance-groups/manager/v1beta2/instanceGroupManagers) + +## Example Usage + +``` +resource "google_replicapool_instance_group_manager" "foobar" { + description = "Terraform test instance group manager" + name = "terraform-test" + instance_template = "${google_compute_instance_template.foobar.self_link}" + target_pools = ["${google_compute_target_pool.foobar.self_link}"] + base_instance_name = "foobar" + zone = "us-central1-a" + target_size = 2 +} +``` + +## Argument Refernce + +The following arguments are supported: + +* `base_instance_name` - (Required) The base instance name to use for +instances in this group. The value must be a valid [RFC1035](https://www.ietf.org/rfc/rfc1035.txt) name. +Supported characters are lowercase letters, numbers, and hyphens (-). Instances +are named by appending a hyphen and a random four-character string to the base +instance name. + +* `description` - (Optional) An optional textual description of the instance +group manager. + +* `instance_template` - (Required) The full URL to an instance template from +which all new instances will be created. + +* `name` - (Required) The name of the instance group manager. Must be 1-63 +characters long and comply with [RFC1035](https://www.ietf.org/rfc/rfc1035.txt). +Supported characters include lowercase letters, numbers, and hyphens. + +* `target_size` - (Optional) If not given at creation time, this defaults to 1. Do not specify this + if you are managing the group with an autoscaler, as this will cause fighting. + +* `target_pools` - (Required) The full URL of all target pools to which new +instances in the group are added. Updating the target pool values does not +affect existing instances. + +* `zone` - (Required) The zone that instances in this group should be created in. + +## Attributes Reference + +The following attributes are exported: + +* `group` - The full URL of the instance group created by the manager. + +* `self_link` - The URL of the created resource.