From 1ae50a18f85a14904e0c64a22d041061d3fc01aa Mon Sep 17 00:00:00 2001 From: stungtoat Date: Fri, 6 Mar 2015 22:13:07 -0800 Subject: [PATCH 01/12] add network field to the network_interface --- builtin/providers/google/resource_compute_instance.go | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/providers/google/resource_compute_instance.go b/builtin/providers/google/resource_compute_instance.go index 3b3e86ded..80defcf4c 100644 --- a/builtin/providers/google/resource_compute_instance.go +++ b/builtin/providers/google/resource_compute_instance.go @@ -564,6 +564,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error networkInterfaces = append(networkInterfaces, map[string]interface{}{ "name": iface.Name, "address": iface.NetworkIP, + "network": iface.Network, "access_config": accessConfigs, }) } From 33496eeaf86e73b9042ffa7ee2ee018e39178e25 Mon Sep 17 00:00:00 2001 From: David Watson Date: Wed, 18 Mar 2015 17:10:39 +0000 Subject: [PATCH 02/12] Update Google API import to point to the new location. --- builtin/providers/google/config.go | 3 +-- builtin/providers/google/disk_type.go | 2 +- builtin/providers/google/operation.go | 3 ++- builtin/providers/google/resource_compute_address.go | 4 ++-- builtin/providers/google/resource_compute_address_test.go | 2 +- builtin/providers/google/resource_compute_disk.go | 4 ++-- builtin/providers/google/resource_compute_disk_test.go | 2 +- builtin/providers/google/resource_compute_firewall.go | 4 ++-- builtin/providers/google/resource_compute_firewall_test.go | 2 +- builtin/providers/google/resource_compute_forwarding_rule.go | 4 ++-- .../providers/google/resource_compute_http_health_check.go | 4 ++-- builtin/providers/google/resource_compute_instance.go | 4 ++-- .../providers/google/resource_compute_instance_template.go | 4 ++-- .../google/resource_compute_instance_template_test.go | 2 +- builtin/providers/google/resource_compute_instance_test.go | 2 +- builtin/providers/google/resource_compute_network.go | 4 ++-- builtin/providers/google/resource_compute_network_test.go | 2 +- builtin/providers/google/resource_compute_route.go | 4 ++-- builtin/providers/google/resource_compute_route_test.go | 2 +- builtin/providers/google/resource_compute_target_pool.go | 4 ++-- 20 files changed, 31 insertions(+), 31 deletions(-) diff --git a/builtin/providers/google/config.go b/builtin/providers/google/config.go index 9ae889482..254cb3ebf 100644 --- a/builtin/providers/google/config.go +++ b/builtin/providers/google/config.go @@ -7,11 +7,10 @@ import ( "net/http" "os" - "code.google.com/p/google-api-go-client/compute/v1" - "golang.org/x/oauth2" "golang.org/x/oauth2/google" "golang.org/x/oauth2/jwt" + "google.golang.org/api/compute/v1" ) // Config is the configuration structure used to instantiate the Google diff --git a/builtin/providers/google/disk_type.go b/builtin/providers/google/disk_type.go index dfea866db..1653337be 100644 --- a/builtin/providers/google/disk_type.go +++ b/builtin/providers/google/disk_type.go @@ -1,7 +1,7 @@ package google import ( - "code.google.com/p/google-api-go-client/compute/v1" + "google.golang.org/api/compute/v1" ) // readDiskType finds the disk type with the given name. diff --git a/builtin/providers/google/operation.go b/builtin/providers/google/operation.go index 32bf79a5e..b1f2f255b 100644 --- a/builtin/providers/google/operation.go +++ b/builtin/providers/google/operation.go @@ -4,7 +4,8 @@ import ( "bytes" "fmt" - "code.google.com/p/google-api-go-client/compute/v1" + "google.golang.org/api/compute/v1" + "github.com/hashicorp/terraform/helper/resource" ) diff --git a/builtin/providers/google/resource_compute_address.go b/builtin/providers/google/resource_compute_address.go index d67ceb190..9bb9547fe 100644 --- a/builtin/providers/google/resource_compute_address.go +++ b/builtin/providers/google/resource_compute_address.go @@ -5,9 +5,9 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeAddress() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_address_test.go b/builtin/providers/google/resource_compute_address_test.go index ba87169d6..90988bb2c 100644 --- a/builtin/providers/google/resource_compute_address_test.go +++ b/builtin/providers/google/resource_compute_address_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeAddress_basic(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_disk.go b/builtin/providers/google/resource_compute_disk.go index 72457b9ac..56b7ed25f 100644 --- a/builtin/providers/google/resource_compute_disk.go +++ b/builtin/providers/google/resource_compute_disk.go @@ -5,9 +5,9 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeDisk() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_disk_test.go b/builtin/providers/google/resource_compute_disk_test.go index f99d9ed62..659affff8 100644 --- a/builtin/providers/google/resource_compute_disk_test.go +++ b/builtin/providers/google/resource_compute_disk_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeDisk_basic(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_firewall.go b/builtin/providers/google/resource_compute_firewall.go index 09d9ca250..2a2433a87 100644 --- a/builtin/providers/google/resource_compute_firewall.go +++ b/builtin/providers/google/resource_compute_firewall.go @@ -6,10 +6,10 @@ import ( "sort" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeFirewall() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_firewall_test.go b/builtin/providers/google/resource_compute_firewall_test.go index 9bb92af20..a4a489fba 100644 --- a/builtin/providers/google/resource_compute_firewall_test.go +++ b/builtin/providers/google/resource_compute_firewall_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeFirewall_basic(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_forwarding_rule.go b/builtin/providers/google/resource_compute_forwarding_rule.go index e87374344..8138ead83 100644 --- a/builtin/providers/google/resource_compute_forwarding_rule.go +++ b/builtin/providers/google/resource_compute_forwarding_rule.go @@ -5,9 +5,9 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeForwardingRule() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_http_health_check.go b/builtin/providers/google/resource_compute_http_health_check.go index 68a4c1348..7f059b860 100644 --- a/builtin/providers/google/resource_compute_http_health_check.go +++ b/builtin/providers/google/resource_compute_http_health_check.go @@ -5,9 +5,9 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeHttpHealthCheck() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_instance.go b/builtin/providers/google/resource_compute_instance.go index 3b3e86ded..803bb277b 100644 --- a/builtin/providers/google/resource_compute_instance.go +++ b/builtin/providers/google/resource_compute_instance.go @@ -5,10 +5,10 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeInstance() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_instance_template.go b/builtin/providers/google/resource_compute_instance_template.go index 074e45695..249b98187 100644 --- a/builtin/providers/google/resource_compute_instance_template.go +++ b/builtin/providers/google/resource_compute_instance_template.go @@ -4,10 +4,10 @@ import ( "fmt" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeInstanceTemplate() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_instance_template_test.go b/builtin/providers/google/resource_compute_instance_template_test.go index 74133089d..d3e696ec9 100644 --- a/builtin/providers/google/resource_compute_instance_template_test.go +++ b/builtin/providers/google/resource_compute_instance_template_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeInstanceTemplate_basic(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_instance_test.go b/builtin/providers/google/resource_compute_instance_test.go index 9d16db521..9c53fae04 100644 --- a/builtin/providers/google/resource_compute_instance_test.go +++ b/builtin/providers/google/resource_compute_instance_test.go @@ -5,9 +5,9 @@ import ( "strings" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeInstance_basic_deprecated_network(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_network.go b/builtin/providers/google/resource_compute_network.go index 4254da721..5e581eff2 100644 --- a/builtin/providers/google/resource_compute_network.go +++ b/builtin/providers/google/resource_compute_network.go @@ -5,9 +5,9 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeNetwork() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_network_test.go b/builtin/providers/google/resource_compute_network_test.go index ea25b0ff4..89827f576 100644 --- a/builtin/providers/google/resource_compute_network_test.go +++ b/builtin/providers/google/resource_compute_network_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeNetwork_basic(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_route.go b/builtin/providers/google/resource_compute_route.go index 02aa72652..aec9e8d3d 100644 --- a/builtin/providers/google/resource_compute_route.go +++ b/builtin/providers/google/resource_compute_route.go @@ -5,10 +5,10 @@ import ( "log" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeRoute() *schema.Resource { diff --git a/builtin/providers/google/resource_compute_route_test.go b/builtin/providers/google/resource_compute_route_test.go index 065842f85..e4b8627e9 100644 --- a/builtin/providers/google/resource_compute_route_test.go +++ b/builtin/providers/google/resource_compute_route_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "code.google.com/p/google-api-go-client/compute/v1" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" + "google.golang.org/api/compute/v1" ) func TestAccComputeRoute_basic(t *testing.T) { diff --git a/builtin/providers/google/resource_compute_target_pool.go b/builtin/providers/google/resource_compute_target_pool.go index 98935b84c..83611e2bd 100644 --- a/builtin/providers/google/resource_compute_target_pool.go +++ b/builtin/providers/google/resource_compute_target_pool.go @@ -6,9 +6,9 @@ import ( "strings" "time" - "code.google.com/p/google-api-go-client/compute/v1" - "code.google.com/p/google-api-go-client/googleapi" "github.com/hashicorp/terraform/helper/schema" + "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" ) func resourceComputeTargetPool() *schema.Resource { From c675c20a48cea55b3995e659dd610ba6a8bfcfe2 Mon Sep 17 00:00:00 2001 From: David Watson Date: Wed, 18 Mar 2015 17:42:03 +0000 Subject: [PATCH 03/12] Update GCE Instance Template tests now that existing disk must exist prior to template creation. --- .../resource_compute_instance_template_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin/providers/google/resource_compute_instance_template_test.go b/builtin/providers/google/resource_compute_instance_template_test.go index 74133089d..a3613d614 100644 --- a/builtin/providers/google/resource_compute_instance_template_test.go +++ b/builtin/providers/google/resource_compute_instance_template_test.go @@ -65,7 +65,7 @@ func TestAccComputeInstanceTemplate_disks(t *testing.T) { testAccCheckComputeInstanceTemplateExists( "google_compute_instance_template.foobar", &instanceTemplate), testAccCheckComputeInstanceTemplateDisk(&instanceTemplate, "debian-7-wheezy-v20140814", true, true), - testAccCheckComputeInstanceTemplateDisk(&instanceTemplate, "foo_existing_disk", false, false), + testAccCheckComputeInstanceTemplateDisk(&instanceTemplate, "terraform-test-foobar", false, false), ), }, }, @@ -252,6 +252,14 @@ resource "google_compute_instance_template" "foobar" { }` const testAccComputeInstanceTemplate_disks = ` +resource "google_compute_disk" "foobar" { + name = "terraform-test-foobar" + image = "debian-7-wheezy-v20140814" + size = 10 + type = "pd-ssd" + zone = "us-central1-a" +} + resource "google_compute_instance_template" "foobar" { name = "terraform-test" machine_type = "n1-standard-1" @@ -263,7 +271,7 @@ resource "google_compute_instance_template" "foobar" { } disk { - source = "foo_existing_disk" + source = "terraform-test-foobar" auto_delete = false boot = false } From 988da2f90b4b1e7cf1ea211d4cdd9afb624209f7 Mon Sep 17 00:00:00 2001 From: David Watson Date: Wed, 18 Mar 2015 17:50:03 +0000 Subject: [PATCH 04/12] Updates to GCE Instances and Instance Templates to allow for false values to be set for the auto_delete setting. --- builtin/providers/google/resource_compute_instance.go | 7 ++----- .../providers/google/resource_compute_instance_template.go | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/builtin/providers/google/resource_compute_instance.go b/builtin/providers/google/resource_compute_instance.go index 3b3e86ded..628dfec64 100644 --- a/builtin/providers/google/resource_compute_instance.go +++ b/builtin/providers/google/resource_compute_instance.go @@ -72,6 +72,7 @@ func resourceComputeInstance() *schema.Resource { "auto_delete": &schema.Schema{ Type: schema.TypeBool, Optional: true, + Default: true, ForceNew: true, }, }, @@ -283,11 +284,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err disk.Type = "PERSISTENT" disk.Mode = "READ_WRITE" disk.Boot = i == 0 - disk.AutoDelete = true - - if v, ok := d.GetOk(prefix + ".auto_delete"); ok { - disk.AutoDelete = v.(bool) - } + disk.AutoDelete = d.Get(prefix + ".auto_delete").(bool) // Load up the disk for this disk if specified if v, ok := d.GetOk(prefix + ".disk"); ok { diff --git a/builtin/providers/google/resource_compute_instance_template.go b/builtin/providers/google/resource_compute_instance_template.go index 074e45695..fef3f0859 100644 --- a/builtin/providers/google/resource_compute_instance_template.go +++ b/builtin/providers/google/resource_compute_instance_template.go @@ -58,6 +58,7 @@ func resourceComputeInstanceTemplate() *schema.Resource { "auto_delete": &schema.Schema{ Type: schema.TypeBool, Optional: true, + Default: true, ForceNew: true, }, @@ -235,11 +236,7 @@ func buildDisks(d *schema.ResourceData, meta interface{}) []*compute.AttachedDis disk.Mode = "READ_WRITE" disk.Interface = "SCSI" disk.Boot = i == 0 - disk.AutoDelete = true - - if v, ok := d.GetOk(prefix + ".auto_delete"); ok { - disk.AutoDelete = v.(bool) - } + disk.AutoDelete = d.Get(prefix + ".auto_delete").(bool) if v, ok := d.GetOk(prefix + ".boot"); ok { disk.Boot = v.(bool) From 9545f26fa01c67d2339cb80163a9a0392c7e1e2a Mon Sep 17 00:00:00 2001 From: Phil Frost Date: Fri, 20 Mar 2015 13:29:11 -0400 Subject: [PATCH 05/12] Correct AWS VPC or route table read functions If the state file contained a VPC or a route table which no longer exists, Terraform would fail to create the correct plan, which is to recreate them. In the case of VPCs, this was due to incorrect error handling. The AWS SDK returns a aws.APIError, not a *aws.APIError on error. When the VPC no longer exists, upon attempting to refresh state Terraform would simply exit with an error. For route tables, the provider would recognize that the route table no longer existed, but would not make the appropriate call to update the state as such. Thus there'd be no crash, but also no plan to re-create the route table. --- builtin/providers/aws/resource_aws_route_table.go | 1 + builtin/providers/aws/resource_aws_vpc.go | 4 ++-- builtin/providers/aws/resource_aws_vpc_test.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route_table.go b/builtin/providers/aws/resource_aws_route_table.go index 6a4b1d3ca..5574e93b2 100644 --- a/builtin/providers/aws/resource_aws_route_table.go +++ b/builtin/providers/aws/resource_aws_route_table.go @@ -107,6 +107,7 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error { return err } if rtRaw == nil { + d.SetId("") return nil } diff --git a/builtin/providers/aws/resource_aws_vpc.go b/builtin/providers/aws/resource_aws_vpc.go index 0ef8aa570..727287039 100644 --- a/builtin/providers/aws/resource_aws_vpc.go +++ b/builtin/providers/aws/resource_aws_vpc.go @@ -238,7 +238,7 @@ func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error { } log.Printf("[INFO] Deleting VPC: %s", d.Id()) if err := ec2conn.DeleteVPC(DeleteVpcOpts); err != nil { - ec2err, ok := err.(*aws.APIError) + ec2err, ok := err.(aws.APIError) if ok && ec2err.Code == "InvalidVpcID.NotFound" { return nil } @@ -258,7 +258,7 @@ func VPCStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc { } resp, err := conn.DescribeVPCs(DescribeVpcOpts) if err != nil { - if ec2err, ok := err.(*aws.APIError); ok && ec2err.Code == "InvalidVpcID.NotFound" { + if ec2err, ok := err.(aws.APIError); ok && ec2err.Code == "InvalidVpcID.NotFound" { resp = nil } else { log.Printf("Error on VPCStateRefresh: %s", err) diff --git a/builtin/providers/aws/resource_aws_vpc_test.go b/builtin/providers/aws/resource_aws_vpc_test.go index 092f47806..ab97249a2 100644 --- a/builtin/providers/aws/resource_aws_vpc_test.go +++ b/builtin/providers/aws/resource_aws_vpc_test.go @@ -132,7 +132,7 @@ func testAccCheckVpcDestroy(s *terraform.State) error { } // Verify the error is what we want - ec2err, ok := err.(*aws.APIError) + ec2err, ok := err.(aws.APIError) if !ok { return err } From b49fba6b61886a4226738325ddd86d939f9351ff Mon Sep 17 00:00:00 2001 From: Phil Frost Date: Fri, 20 Mar 2015 14:44:42 -0400 Subject: [PATCH 06/12] Don't error when enabling DNS hostnames in a VPC The AWS API call ModifyVpcAttribute will allow only one attribute to be modified at a time. Modifying both results in the error: Fields for multiple attribute types specified: enableDnsHostnames, enableDnsSupport Retructure the provider to honor this restriction. Also, enable DNS support before attempting to enable DNS hostnames, since the former is a prerequisite of the latter. Additionally, fix what must have been a copy&paste error, setting enable_dns_support to the value of enable_dns_hostnames. --- builtin/providers/aws/resource_aws_vpc.go | 46 ++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/builtin/providers/aws/resource_aws_vpc.go b/builtin/providers/aws/resource_aws_vpc.go index 727287039..7b27f3b6e 100644 --- a/builtin/providers/aws/resource_aws_vpc.go +++ b/builtin/providers/aws/resource_aws_vpc.go @@ -185,29 +185,14 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error { // Turn on partial mode d.Partial(true) vpcid := d.Id() - modifyOpts := &ec2.ModifyVPCAttributeRequest{ - VPCID: &vpcid, - } - if d.HasChange("enable_dns_hostnames") { - val := d.Get("enable_dns_hostnames").(bool) - modifyOpts.EnableDNSHostnames = &ec2.AttributeBooleanValue{ - Value: &val, - } - - log.Printf( - "[INFO] Modifying enable_dns_hostnames vpc attribute for %s: %#v", - d.Id(), modifyOpts) - if err := ec2conn.ModifyVPCAttribute(modifyOpts); err != nil { - return err - } - - d.SetPartial("enable_dns_hostnames") - } if d.HasChange("enable_dns_support") { - val := d.Get("enable_dns_hostnames").(bool) - modifyOpts.EnableDNSSupport = &ec2.AttributeBooleanValue{ - Value: &val, + val := d.Get("enable_dns_support").(bool) + modifyOpts := &ec2.ModifyVPCAttributeRequest{ + VPCID: &vpcid, + EnableDNSSupport: &ec2.AttributeBooleanValue{ + Value: &val, + }, } log.Printf( @@ -220,6 +205,25 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error { d.SetPartial("enable_dns_support") } + if d.HasChange("enable_dns_hostnames") { + val := d.Get("enable_dns_hostnames").(bool) + modifyOpts := &ec2.ModifyVPCAttributeRequest{ + VPCID: &vpcid, + EnableDNSHostnames: &ec2.AttributeBooleanValue{ + Value: &val, + }, + } + + log.Printf( + "[INFO] Modifying enable_dns_hostnames vpc attribute for %s: %#v", + d.Id(), modifyOpts) + if err := ec2conn.ModifyVPCAttribute(modifyOpts); err != nil { + return err + } + + d.SetPartial("enable_dns_hostnames") + } + if err := setTags(ec2conn, d); err != nil { return err } else { From 85fc1bca330b417262f249a2ce8150e87549841a Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Sat, 21 Mar 2015 09:16:16 -0500 Subject: [PATCH 07/12] 'project' should be set to the project's ID, not its name. --- website/source/docs/providers/google/index.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/providers/google/index.html.markdown b/website/source/docs/providers/google/index.html.markdown index cacf7599b..6ba08b844 100644 --- a/website/source/docs/providers/google/index.html.markdown +++ b/website/source/docs/providers/google/index.html.markdown @@ -40,7 +40,7 @@ The following keys can be used to configure the provider. are running terraform from a GCE instance with a properly-configured [Compute Engine Service Account](https://cloud.google.com/compute/docs/authentication). -* `project` - (Required) The name of the project to apply any resources to. +* `project` - (Required) The ID of the project to apply any resources to. * `region` - (Required) The region to operate under. From 9d75fa72aba677e84dc4638a13de7692d72d9051 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 24 Mar 2015 11:45:20 -0500 Subject: [PATCH 08/12] Add disk size to google_compute_instance disk blocks. --- builtin/providers/google/resource_compute_instance.go | 11 +++++++++++ .../providers/google/r/compute_instance.html.markdown | 3 +++ 2 files changed, 14 insertions(+) diff --git a/builtin/providers/google/resource_compute_instance.go b/builtin/providers/google/resource_compute_instance.go index 3b3e86ded..572d77310 100644 --- a/builtin/providers/google/resource_compute_instance.go +++ b/builtin/providers/google/resource_compute_instance.go @@ -74,6 +74,12 @@ func resourceComputeInstance() *schema.Resource { Optional: true, ForceNew: true, }, + + "size": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, }, }, }, @@ -331,6 +337,11 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err disk.InitializeParams.DiskType = diskType.SelfLink } + if v, ok := d.GetOk(prefix + ".size"); ok { + diskSizeGb := v.(int) + disk.InitializeParams.DiskSizeGb = int64(diskSizeGb) + } + disks = append(disks, &disk) } diff --git a/website/source/docs/providers/google/r/compute_instance.html.markdown b/website/source/docs/providers/google/r/compute_instance.html.markdown index 5c6cfe027..3d3104d17 100644 --- a/website/source/docs/providers/google/r/compute_instance.html.markdown +++ b/website/source/docs/providers/google/r/compute_instance.html.markdown @@ -93,6 +93,9 @@ The `disk` block supports: * `type` - (Optional) The GCE disk type. +* `size` - (Optional) The size of the image in gigabytes. If not specified, + it will inherit the size of its base image. + The `network_interface` block supports: * `network` - (Required) The name of the network to attach this interface to. From 5e8535c5e0282d0dbe4368712d71ecb4b0859793 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 26 Mar 2015 10:13:57 -0700 Subject: [PATCH 09/12] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c694a37..733e2d10c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ IMPROVEMENTS: like refresh. * core: Autoload `terraform.tfvars.json` as well as `terraform.tfvars` [GH-1030] * core: `.tf` files that start with a period are now ignored. [GH-1227] + * providers/google: Add `size` option to disk blocks for instances. [GH-1284] BUG FIXES: From 3565ae034e1aec50a63d2abe7dcd2cb7dfe7579a Mon Sep 17 00:00:00 2001 From: Anton Tereshchenkov Date: Sun, 25 Jan 2015 12:30:09 +0800 Subject: [PATCH 10/12] providers/digitalocean: force fqdn in dns rr value Fixes a bug that forces DNS record to be recreated when dealing with records that have domain values (CNAME, MX, NS, etc.) --- .../resource_digitalocean_record.go | 10 +++- .../resource_digitalocean_record_test.go | 52 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/builtin/providers/digitalocean/resource_digitalocean_record.go b/builtin/providers/digitalocean/resource_digitalocean_record.go index d365e4706..1dcf7a3a9 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_record.go +++ b/builtin/providers/digitalocean/resource_digitalocean_record.go @@ -68,10 +68,18 @@ func resourceDigitalOceanRecord() *schema.Resource { func resourceDigitalOceanRecordCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*digitalocean.Client) + rrValue := d.Get("value").(string) + // Ensure all records with domain value are absolute (ending with dot) + if t := d.Get("type").(string); t == "CNAME" || t == "MX" || t == "NS" || t == "SRV" { + if rrValue[len(rrValue)-1] != '.' { + rrValue += "." + } + } + newRecord := digitalocean.CreateRecord{ Type: d.Get("type").(string), Name: d.Get("name").(string), - Data: d.Get("value").(string), + Data: rrValue, Priority: d.Get("priority").(string), Port: d.Get("port").(string), Weight: d.Get("weight").(string), diff --git a/builtin/providers/digitalocean/resource_digitalocean_record_test.go b/builtin/providers/digitalocean/resource_digitalocean_record_test.go index 66ac2bb5f..dd4b1010f 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_record_test.go +++ b/builtin/providers/digitalocean/resource_digitalocean_record_test.go @@ -76,6 +76,33 @@ func TestAccDigitalOceanRecord_Updated(t *testing.T) { }) } +func TestAccDigitalOceanRecord_HostnameValue(t *testing.T) { + var record digitalocean.Record + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDigitalOceanRecordDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckDigitalOceanRecordConfig_cname, + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanRecordExists("digitalocean_record.foobar", &record), + testAccCheckDigitalOceanRecordAttributesHostname(&record), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "name", "terraform"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "domain", "foobar-test-terraform.com"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "value", "a.foobar-test-terraform.com"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "type", "CNAME"), + ), + }, + }, + }) +} + func testAccCheckDigitalOceanRecordDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*digitalocean.Client) @@ -146,6 +173,17 @@ func testAccCheckDigitalOceanRecordExists(n string, record *digitalocean.Record) } } +func testAccCheckDigitalOceanRecordAttributesHostname(record *digitalocean.Record) resource.TestCheckFunc { + return func(s *terraform.State) error { + + if record.Data != "a.foobar-test-terraform.com" { + return fmt.Errorf("Bad value: %s", record.Data) + } + + return nil + } +} + const testAccCheckDigitalOceanRecordConfig_basic = ` resource "digitalocean_domain" "foobar" { name = "foobar-test-terraform.com" @@ -173,3 +211,17 @@ resource "digitalocean_record" "foobar" { value = "192.168.0.11" type = "A" }` + +const testAccCheckDigitalOceanRecordConfig_cname = ` +resource "digitalocean_domain" "foobar" { + name = "foobar-test-terraform.com" + ip_address = "192.168.0.10" +} + +resource "digitalocean_record" "foobar" { + domain = "${digitalocean_domain.foobar.name}" + + name = "terraform" + value = "a.foobar-test-terraform.com" + type = "CNAME" +}` From 6f76340192147f7a1f29a2831d2ed5cb6f167b8b Mon Sep 17 00:00:00 2001 From: Anton Tereshchenkov Date: Sat, 28 Feb 2015 18:55:10 +0800 Subject: [PATCH 11/12] providers/digitalocean: add dot in GET response Added tests for relative and external CNAME values. --- .../resource_digitalocean_record.go | 25 +++-- .../resource_digitalocean_record_test.go | 94 +++++++++++++++++-- 2 files changed, 103 insertions(+), 16 deletions(-) diff --git a/builtin/providers/digitalocean/resource_digitalocean_record.go b/builtin/providers/digitalocean/resource_digitalocean_record.go index 1dcf7a3a9..78a4e8911 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_record.go +++ b/builtin/providers/digitalocean/resource_digitalocean_record.go @@ -68,18 +68,10 @@ func resourceDigitalOceanRecord() *schema.Resource { func resourceDigitalOceanRecordCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*digitalocean.Client) - rrValue := d.Get("value").(string) - // Ensure all records with domain value are absolute (ending with dot) - if t := d.Get("type").(string); t == "CNAME" || t == "MX" || t == "NS" || t == "SRV" { - if rrValue[len(rrValue)-1] != '.' { - rrValue += "." - } - } - newRecord := digitalocean.CreateRecord{ Type: d.Get("type").(string), Name: d.Get("name").(string), - Data: rrValue, + Data: d.Get("value").(string), Priority: d.Get("priority").(string), Port: d.Get("port").(string), Weight: d.Get("weight").(string), @@ -99,8 +91,9 @@ func resourceDigitalOceanRecordCreate(d *schema.ResourceData, meta interface{}) func resourceDigitalOceanRecordRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*digitalocean.Client) + domain := d.Get("domain").(string) - rec, err := client.RetrieveRecord(d.Get("domain").(string), d.Id()) + rec, err := client.RetrieveRecord(domain, d.Id()) if err != nil { // If the record is somehow already destroyed, mark as // succesfully gone @@ -112,6 +105,18 @@ func resourceDigitalOceanRecordRead(d *schema.ResourceData, meta interface{}) er return err } + // Update response data for records with domain value + if t := rec.Type; t == "CNAME" || t == "MX" || t == "NS" || t == "SRV" { + // Append dot to response if resource value is absolute + if value := d.Get("value").(string); strings.HasSuffix(value, ".") { + rec.Data += "." + // If resource value ends with current domain, make response data absolute + if strings.HasSuffix(value, domain+".") { + rec.Data += domain + "." + } + } + } + d.Set("name", rec.Name) d.Set("type", rec.Type) d.Set("value", rec.Data) diff --git a/builtin/providers/digitalocean/resource_digitalocean_record_test.go b/builtin/providers/digitalocean/resource_digitalocean_record_test.go index dd4b1010f..139fd30b7 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_record_test.go +++ b/builtin/providers/digitalocean/resource_digitalocean_record_test.go @@ -88,13 +88,67 @@ func TestAccDigitalOceanRecord_HostnameValue(t *testing.T) { Config: testAccCheckDigitalOceanRecordConfig_cname, Check: resource.ComposeTestCheckFunc( testAccCheckDigitalOceanRecordExists("digitalocean_record.foobar", &record), - testAccCheckDigitalOceanRecordAttributesHostname(&record), + testAccCheckDigitalOceanRecordAttributesHostname("a", &record), resource.TestCheckResourceAttr( "digitalocean_record.foobar", "name", "terraform"), resource.TestCheckResourceAttr( "digitalocean_record.foobar", "domain", "foobar-test-terraform.com"), resource.TestCheckResourceAttr( - "digitalocean_record.foobar", "value", "a.foobar-test-terraform.com"), + "digitalocean_record.foobar", "value", "a.foobar-test-terraform.com."), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "type", "CNAME"), + ), + }, + }, + }) +} + +func TestAccDigitalOceanRecord_RelativeHostnameValue(t *testing.T) { + var record digitalocean.Record + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDigitalOceanRecordDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckDigitalOceanRecordConfig_relative_cname, + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanRecordExists("digitalocean_record.foobar", &record), + testAccCheckDigitalOceanRecordAttributesHostname("a.b", &record), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "name", "terraform"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "domain", "foobar-test-terraform.com"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "value", "a.b"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "type", "CNAME"), + ), + }, + }, + }) +} + +func TestAccDigitalOceanRecord_ExternalHostnameValue(t *testing.T) { + var record digitalocean.Record + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDigitalOceanRecordDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckDigitalOceanRecordConfig_external_cname, + Check: resource.ComposeTestCheckFunc( + testAccCheckDigitalOceanRecordExists("digitalocean_record.foobar", &record), + testAccCheckDigitalOceanRecordAttributesHostname("a.foobar-test-terraform.net", &record), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "name", "terraform"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "domain", "foobar-test-terraform.com"), + resource.TestCheckResourceAttr( + "digitalocean_record.foobar", "value", "a.foobar-test-terraform.net."), resource.TestCheckResourceAttr( "digitalocean_record.foobar", "type", "CNAME"), ), @@ -173,11 +227,11 @@ func testAccCheckDigitalOceanRecordExists(n string, record *digitalocean.Record) } } -func testAccCheckDigitalOceanRecordAttributesHostname(record *digitalocean.Record) resource.TestCheckFunc { +func testAccCheckDigitalOceanRecordAttributesHostname(data string, record *digitalocean.Record) resource.TestCheckFunc { return func(s *terraform.State) error { - if record.Data != "a.foobar-test-terraform.com" { - return fmt.Errorf("Bad value: %s", record.Data) + if record.Data != data { + return fmt.Errorf("Bad value: expected %s, got %s", data, record.Data) } return nil @@ -222,6 +276,34 @@ resource "digitalocean_record" "foobar" { domain = "${digitalocean_domain.foobar.name}" name = "terraform" - value = "a.foobar-test-terraform.com" + value = "a.foobar-test-terraform.com." + type = "CNAME" +}` + +const testAccCheckDigitalOceanRecordConfig_relative_cname = ` +resource "digitalocean_domain" "foobar" { + name = "foobar-test-terraform.com" + ip_address = "192.168.0.10" +} + +resource "digitalocean_record" "foobar" { + domain = "${digitalocean_domain.foobar.name}" + + name = "terraform" + value = "a.b" + type = "CNAME" +}` + +const testAccCheckDigitalOceanRecordConfig_external_cname = ` +resource "digitalocean_domain" "foobar" { + name = "foobar-test-terraform.com" + ip_address = "192.168.0.10" +} + +resource "digitalocean_record" "foobar" { + domain = "${digitalocean_domain.foobar.name}" + + name = "terraform" + value = "a.foobar-test-terraform.net." type = "CNAME" }` From e0df2a948c0bb15fdd534c47fa6db1e20ee3e4c5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 26 Mar 2015 10:58:42 -0700 Subject: [PATCH 12/12] update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 733e2d10c..ad3fa30c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,8 @@ BUG FIXES: * providers/aws: Longer wait times for route53 records (30 mins). [GH-1164] * providers/digitalocean: Waits until droplet is ready to be destroyed [GH-1057] * providers/digitalocean: More lenient about 404's while waiting [GH-1062] + * providers/digitalocean: FQDN for domain records in CNAME, MX, NS, etc. + Also fixes invalid updates in plans. [GH-863] * providers/google: Network data in state was not being stored. [GH-1095] PLUGIN CHANGES: