Skip to content

Commit

Permalink
Merge branch 'master' into gke-regional-clusters-support
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-amarnath authored Mar 19, 2018
2 parents 333a9e7 + c07cb1c commit fc3d5d8
Show file tree
Hide file tree
Showing 112 changed files with 2,874 additions and 1,196 deletions.
77 changes: 53 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,62 @@
## 1.7.0 (Unreleased)
## 1.8.0 (Unreleased)

BACKWARDS INCOMPATIBILITIES / NOTES:
* `google_dataproc_cluster.delete_autogen_bucket` is now deprecated [GH-1171]

FEATURES:
* **New Resource** `google_organization_iam_policy` (see docs for caveats) [GH-1196]

IMPROVEMENTS:
* container: un-deprecate `google_container_node_pool.initial_node_count` [GH-1176]
* container: Add support for pod security policy [GH-1192]
* container: Add support for GKE metadata concealment [GH-1199]
* container: Add support for GKE network policy config addon. [GH-1200]
* container: Add support for `instance_group_url` in `google_container_nodel_pool` [GH-1207]
* compute: Rolling update support for instance group manager [GH-1137]
* compute: Add `cdn_policy` field to backend service [GH-1208]
* compute: Add support for deletion protection. [GH-1205]
* all: IAM resources now wait for propagation before reporting created. [GH-1197]

BUG FIXES:
* compute: Properly set `image_id` field on `data_google_compute_image` in state [GH-1217]
* compute: Properly set `backend` field on `google_compute_backend_service` in state [GH-1217]
* compute: Properly set `project` field on `google_compute_project_metadata` in state [GH-1217]
* compute: Properly set `backend` field on `google_compute_region_backend_service` in state [GH-1217]
* dataproc: Properly set `cluster_config.0.intiialization_action` on `google_dataproc_cluster` in state [GH-1217]

## 1.7.0 (March 12, 2018)

Features:
* **New Data Source** `google_compute_forwarding_rule` [GH-1078]
* **New Data Source** `google_compute_vpn_gateway` [GH-1071]
* **New Data Source** `google_project` [GH-1111]
* **New Data Source** `google_storage_project_service_account` [GH-1110]
* **New Resource** `google_folder_iam_binding` [GH-1076]
* **New Resource** `google_folder_iam_member` [GH-1076]
* **New Resource** `google_project_usage_export_bucket` [GH-1080]
* **New Data Source** `google_compute_forwarding_rule` ([#1078](https://github.com/terraform-providers/terraform-provider-google/issues/1078))
* **New Data Source** `google_compute_vpn_gateway` ([#1071](https://github.com/terraform-providers/terraform-provider-google/issues/1071))
* **New Data Source** `google_project` ([#1111](https://github.com/terraform-providers/terraform-provider-google/issues/1111))
* **New Data Source** `google_compute_backend_service` ([#1150](https://github.com/terraform-providers/terraform-provider-google/issues/1150))
* **New Data Source** `google_storage_project_service_account` ([#1110](https://github.com/terraform-providers/terraform-provider-google/issues/1110))
* **New Data Source** `google_compute_default_service_account` ([#1119](https://github.com/terraform-providers/terraform-provider-google/issues/1119))
* **New Resource** `google_folder_iam_binding` ([#1076](https://github.com/terraform-providers/terraform-provider-google/issues/1076))
* **New Resource** `google_folder_iam_member` ([#1076](https://github.com/terraform-providers/terraform-provider-google/issues/1076))
* **New Resource** `google_project_usage_export_bucket` ([#1080](https://github.com/terraform-providers/terraform-provider-google/issues/1080))

IMPROVEMENTS:
* compute: add support for updating alias ips in instances [GH-1084]
* compute: allow setting a route resource's `description` attribute [GH-1088]
* compute: allow lowercase ip protocols in forwarding rules [GH-1118]
* compute: `google_compute_zones` datasource accepts a `project` parameter [GH-1122]
* compute: Support `distributionPolicy` when creating regional instance group managers. [GH-1092]
* container: Fail if the ip_allocation_policy doesn't specify secondary range names [GH-1065]
* container: Allow specifying accelerators in cluster node_config. [GH-1115]
* pubsub: Add project field to iam pubsub topic resources [GH-1154]
* sql: Support multiple users with the same name for different host for 1st gen SQL instances. [GH-1066]
* sql: Add SQL DB Instance attribute `first_ip_address` [GH-1050]
* compute: add support for updating alias ips in instances ([#1084](https://github.com/terraform-providers/terraform-provider-google/issues/1084))
* compute: allow setting a route resource's `description` attribute ([#1088](https://github.com/terraform-providers/terraform-provider-google/issues/1088))
* compute: allow lowercase ip protocols in forwarding rules ([#1118](https://github.com/terraform-providers/terraform-provider-google/issues/1118))
* compute: `google_compute_zones` datasource accepts a `project` parameter ([#1122](https://github.com/terraform-providers/terraform-provider-google/issues/1122))
* compute: Support `distributionPolicy` when creating regional instance group managers. ([#1092](https://github.com/terraform-providers/terraform-provider-google/issues/1092))
* compute: Timeout customization for `google_compute_backend_bucket`, `google_compute_http_health_check`, and `google_compute_https_health_check` ([#1177](https://github.com/terraform-providers/terraform-provider-google/issues/1177))
* container: Fail if the ip_allocation_policy doesn't specify secondary range names ([#1065](https://github.com/terraform-providers/terraform-provider-google/issues/1065))
* container: Allow specifying accelerators in cluster node_config. ([#1115](https://github.com/terraform-providers/terraform-provider-google/issues/1115))
* pubsub: Add project field to iam pubsub topic resources ([#1154](https://github.com/terraform-providers/terraform-provider-google/issues/1154))
* sql: Support multiple users with the same name for different host for 1st gen SQL instances. ([#1066](https://github.com/terraform-providers/terraform-provider-google/issues/1066))
* sql: Add SQL DB Instance attribute `first_ip_address` ([#1050](https://github.com/terraform-providers/terraform-provider-google/issues/1050))

BUG FIXES:
* compute: Don't store disk in state if it didn't create [GH-1129]
* compute: Check set equality for service account scope changes [GH-1130]
* compute: Disk now accepts project id with '.' and ':' [GH-1145]
* dataproc: fix typos in pyspark dataproc job resource that led to args not working [GH-1120]
* dns: fix perpetual diffs when names aren't all uppercase or if TXT records aren't quoted [GH-1141]
* spanner: Accepts project id with '.' and ':' [GH-1151]
* compute: Don't store disk in state if it didn't create ([#1129](https://github.com/terraform-providers/terraform-provider-google/issues/1129))
* compute: Check set equality for service account scope changes ([#1130](https://github.com/terraform-providers/terraform-provider-google/issues/1130))
* compute: Disk now accepts project id with '.' and ':' ([#1145](https://github.com/terraform-providers/terraform-provider-google/issues/1145))
* dataproc: fix typos in pyspark dataproc job resource that led to args not working ([#1120](https://github.com/terraform-providers/terraform-provider-google/issues/1120))
* dns: fix perpetual diffs when names aren't all uppercase or if TXT records aren't quoted ([#1141](https://github.com/terraform-providers/terraform-provider-google/issues/1141))
* spanner: Accepts project id with '.' and ':' ([#1151](https://github.com/terraform-providers/terraform-provider-google/issues/1151))

## 1.6.0 (February 09, 2018)

Expand Down
7 changes: 7 additions & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ func (c *Config) loadAndValidate() error {
}
c.clientContainer.UserAgent = userAgent

log.Printf("[INFO] Instantiating GKE Beta client...")
c.clientContainerBeta, err = containerBeta.New(client)
if err != nil {
return err
}
c.clientContainerBeta.UserAgent = userAgent

log.Printf("[INFO] Instantiating Google Cloud DNS client...")
c.clientDns, err = dns.New(client)
if err != nil {
Expand Down
28 changes: 28 additions & 0 deletions google/data_source_google_compute_backend_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package google

import (
"github.com/hashicorp/terraform/helper/schema"
)

func dataSourceGoogleComputeBackendService() *schema.Resource {
dsSchema := datasourceSchemaFromResourceSchema(resourceComputeBackendService().Schema)

// Set 'Required' schema elements
addRequiredFieldsToSchema(dsSchema, "name")

// Set 'Optional' schema elements
addOptionalFieldsToSchema(dsSchema, "project")

return &schema.Resource{
Read: dataSourceComputeBackendServiceRead,
Schema: dsSchema,
}
}

func dataSourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) error {
serviceName := d.Get("name").(string)

d.SetId(serviceName)

return resourceComputeBackendServiceRead(d, meta)
}
85 changes: 85 additions & 0 deletions google/data_source_google_compute_backend_service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package google

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)

func TestAccDataSourceComputeBackendService_basic(t *testing.T) {
t.Parallel()

serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
checkName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeBackendServiceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDataSourceComputeBackendService_basic(serviceName, checkName),
Check: testAccDataSourceComputeBackendServiceCheck("data.google_compute_backend_service.baz", "google_compute_backend_service.foobar"),
},
},
})
}

func testAccDataSourceComputeBackendServiceCheck(dsName, rsName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[rsName]
if !ok {
return fmt.Errorf("can't find resource called %s in state", rsName)
}

ds, ok := s.RootModule().Resources[dsName]
if !ok {
return fmt.Errorf("can't find data source called %s in state", dsName)
}

dsAttr := ds.Primary.Attributes
rsAttr := rs.Primary.Attributes

attrsToTest := []string{
"id",
"name",
"description",
"self_link",
"fingerprint",
"port_name",
"protocol",
}

for _, attrToTest := range attrsToTest {
if dsAttr[attrToTest] != rsAttr[attrToTest] {
return fmt.Errorf("%s is %s; want %s", attrToTest, dsAttr[attrToTest], rsAttr[attrToTest])
}
}

return nil
}
}

func testAccDataSourceComputeBackendService_basic(serviceName, checkName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "%s"
description = "foobar backend service"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
}
resource "google_compute_http_health_check" "zero" {
name = "%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
data "google_compute_backend_service" "baz" {
name = "${google_compute_backend_service.foobar.name}"
}
`, serviceName, checkName)
}
40 changes: 40 additions & 0 deletions google/data_source_google_compute_default_service_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package google

import (
"github.com/hashicorp/terraform/helper/schema"
)

func dataSourceGoogleComputeDefaultServiceAccount() *schema.Resource {
return &schema.Resource{
Read: dataSourceGoogleComputeDefaultServiceAccountRead,
Schema: map[string]*schema.Schema{
"email": {
Type: schema.TypeString,
Optional: true,
},
"project": {
Type: schema.TypeString,
Optional: true,
},
},
}
}

func dataSourceGoogleComputeDefaultServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

project, err := getProject(d, config)
if err != nil {
return err
}

projectCompResource, err := config.clientCompute.Projects.Get(project).Do()
if err != nil {
return handleNotFoundError(err, d, "GCE service account not found")
}

d.SetId(projectCompResource.DefaultServiceAccount)
d.Set("email", projectCompResource.DefaultServiceAccount)
d.Set("project", project)
return nil
}
31 changes: 31 additions & 0 deletions google/data_source_google_compute_default_service_account_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package google

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccDataSourceGoogleComputeDefaultServiceAccount_basic(t *testing.T) {
t.Parallel()

resourceName := "data.google_compute_default_service_account.default"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckGoogleComputeDefaultServiceAccount_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(resourceName, "id"),
resource.TestCheckResourceAttrSet(resourceName, "email"),
),
},
},
})
}

const testAccCheckGoogleComputeDefaultServiceAccount_basic = `
data "google_compute_default_service_account" "default" { }
`
3 changes: 2 additions & 1 deletion google/data_source_google_compute_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package google
import (
"fmt"
"log"
"strconv"
"strings"

"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -149,7 +150,7 @@ func dataSourceGoogleComputeImageRead(d *schema.ResourceData, meta interface{})
d.Set("creation_timestamp", image.CreationTimestamp)
d.Set("description", image.Description)
d.Set("disk_size_gb", image.DiskSizeGb)
d.Set("image_id", image.Id)
d.Set("image_id", strconv.FormatUint(image.Id, 10))
d.Set("image_encryption_key_sha256", ieks256)
d.Set("label_fingerprint", image.LabelFingerprint)
d.Set("labels", image.Labels)
Expand Down
8 changes: 4 additions & 4 deletions google/data_source_google_compute_region_instance_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package google
import (
"errors"
"fmt"
"github.com/hashicorp/terraform/helper/schema"
compute "google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
"log"
"net/url"
"strconv"
"strings"

"github.com/hashicorp/terraform/helper/schema"
compute "google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
)

func dataSourceGoogleComputeRegionInstanceGroup() *schema.Resource {
Expand Down Expand Up @@ -137,7 +138,6 @@ func dataSourceComputeRegionInstanceGroupRead(d *schema.ResourceData, meta inter
} else {
d.Set("instances", flattenInstancesWithNamedPorts(members.Items))
}
d.Set("kind", instanceGroup.Kind)
d.SetId(strconv.FormatUint(instanceGroup.Id, 16))
d.Set("self_link", instanceGroup.SelfLink)
d.Set("name", name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ package google

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"testing"
)

func TestAccDataSourceRegionInstanceGroup(t *testing.T) {
t.Parallel()
name := "acctest-" + acctest.RandString(6)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceRegionInstanceGroup_basic("foobarbaz"),
Config: testAccDataSourceRegionInstanceGroup_basic(name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "name", "foobarbaz"),
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "name", name),
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "project", getTestProjectFromEnv()),
resource.TestCheckResourceAttr("data.google_compute_region_instance_group.data_source", "instances.#", "10")),
},
Expand Down
Loading

0 comments on commit fc3d5d8

Please sign in to comment.