mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-05 17:52:38 +00:00
d60381a693
Hi there, Here is an attempt to implement canary releases ( #1252 ). This is the first time I write golang and make a terraform contribution, I opened the PR to obtain feedback and advices so please let me know how I can improve this code! In addition I used `make fmt` to format the code but left some lines bigger than 80 characters, do I need to split them ? I tested the feature against a project with the following configuration: ``` resource "google_compute_health_check" "mikael-hackathon-healthcheck" { name = "mikael-hackathon-healthcheck" check_interval_sec = 1 timeout_sec = 1 healthy_threshold = 2 unhealthy_threshold = 10 http_health_check { request_path = "/" port = "80" } } resource "google_compute_instance_template" "mikael-hackaton-template" { name_prefix = "mikael-hackaton-" description = "This template is used to create app server instances." tags = ["loadbalanced", "internal-web", "hackaton"] labels = { environment = "hackaton" } instance_description = "Hackaton demo rolling upgrade" machine_type = "n1-standard-1" can_ip_forward = false scheduling { automatic_restart = true on_host_maintenance = "MIGRATE" } disk { source_image = "debian-cloud/debian-9" disk_type = "pd-standard" disk_size_gb = 20 auto_delete = true boot = true } network_interface { network = "default" access_config = {} } service_account { email = "${google_service_account.mikael-hackaton.email}" scopes = ["cloud-platform"] } lifecycle { create_before_destroy = true } metadata_startup_script = "apt-get update && apt-get install -y apache2 && echo I am stable version at $(hostname) > /var/www/html/index.html" } resource "google_compute_instance_template" "mikael-hackaton-template-canary" { name_prefix = "mikael-hackaton-canary" description = "This template is used to create app server instances." tags = ["loadbalanced", "internal-web", "hackaton"] labels = { environment = "hackaton" } instance_description = "Hackaton demo rolling upgrade" machine_type = "n1-standard-1" can_ip_forward = false scheduling { automatic_restart = true on_host_maintenance = "MIGRATE" } disk { source_image = "debian-cloud/debian-9" disk_type = "pd-standard" disk_size_gb = 20 auto_delete = true boot = true } network_interface { network = "default" access_config = {} } service_account { email = "${google_service_account.mikael-hackaton.email}" scopes = ["cloud-platform"] } lifecycle { create_before_destroy = true } metadata_startup_script = "apt-get update && apt-get install -y apache2 && echo I am a canary at $(hostname) > /var/www/html/index.html" } resource "google_compute_target_pool" "mikael-hackaton-target-pool" { name = "mikael-hackaton-target-pool" } resource "google_compute_instance_group_manager" "mikael-hackaton-manager" { name = "mikael-hackaton-manager" base_instance_name = "mikael-hackaton" #instance_template = "${google_compute_instance_template.mikael-hackaton-template.self_link}" update_strategy = "ROLLING_UPDATE" zone = "${var.zone}" target_pools = ["${google_compute_target_pool.mikael-hackaton-target-pool.self_link}"] target_size = 5 version { name = "primary" instance_template = "${google_compute_instance_template.mikael-hackaton-template.self_link}" } version { name = "canary" instance_template = "${google_compute_instance_template.mikael-hackaton-template-canary.self_link}" target_size_fixed = 1 } named_port { name = "http" port = 80 } auto_healing_policies { health_check = "${google_compute_health_check.mikael-hackathon-healthcheck.self_link}" initial_delay_sec = 10 } rolling_update_policy { type = "PROACTIVE" minimal_action = "REPLACE" max_surge_percent = 100 max_unavailable_percent = 50 min_ready_sec = 5 } } ``` |
||
---|---|---|
.. | ||
docs | ||
google.erb |