Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-picks to support 1.20.0 release. #2567

Merged
merged 82 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
09dd0ac
Add more import paths for google_service_account. (#2261)
modular-magician Oct 16, 2018
8f7a582
Update CHANGELOG.md
emilymye Oct 16, 2018
0b03e92
Docs: Make "All Providers" a backwards arrow (#2266)
rileykarson Oct 16, 2018
48a7a94
Fix Composer Environment machineType parsing
modular-magician Oct 17, 2018
890318b
Add import tests for google_cloudiot_registry (#2276)
modular-magician Oct 17, 2018
cf613b4
Add support for google_storage_object_access_control (#2256)
modular-magician Oct 17, 2018
90cd274
Update CHANGELOG.md
rileykarson Oct 17, 2018
88f089f
Output from magician generating into ga and beta providers (#2271)
modular-magician Oct 19, 2018
4286109
use correct cloud console link (#2293)
danawillow Oct 19, 2018
3ece928
More import formats and fix name validation for spanner databases
modular-magician Oct 19, 2018
47113ba
Fix composer website (#2299)
rvrignaud Oct 22, 2018
5a91d52
Added London and Sydney BigQuery regions
lnesteroff Oct 24, 2018
06d085b
Update CHANGELOG.md
chrisst Oct 25, 2018
1e90ab5
Add support for google_cloudfunctions_function runtime (#2340)
modular-magician Oct 26, 2018
c411523
Update CHANGELOG.md
rileykarson Oct 26, 2018
9bee241
support KMS encryption for instance templates
chrisst Oct 26, 2018
66b8853
Increase redis timeouts (#2351)
modular-magician Oct 29, 2018
8d64a91
Update composer timeouts (#2354)
modular-magician Oct 29, 2018
6b1e539
add retries on create for container cluster (#2352)
modular-magician Oct 29, 2018
690bc65
Remove duplicate storage_object_access_control test. (#2349)
rileykarson Oct 29, 2018
3b603e0
Generate DefaultObjectAccessControl in Terraform (#2358)
modular-magician Oct 30, 2018
3432946
Update CHANGELOG.md
rileykarson Oct 30, 2018
1cbffe1
Fix typo in resource name (#2365)
rolandkool Oct 31, 2018
f3f283a
regional and private clusters are in GA now (#2364)
modular-magician Oct 31, 2018
22eee62
Update CHANGELOG.md
danawillow Oct 31, 2018
c1f057b
Regional Clusters are GA followup (#2387)
modular-magician Nov 2, 2018
8b590a9
Deprecated network_interface.address in code in instance template. (#…
modular-magician Nov 2, 2018
14fa144
Update CONTRIBUTING.md (#2407)
nat-henderson Nov 5, 2018
1f0a63c
Add support for new-style cloud functions triggers. (#2412)
modular-magician Nov 6, 2018
b2eab9b
Update CHANGELOG.md
rileykarson Nov 6, 2018
820996b
Add import support to project metadata. (#2423)
modular-magician Nov 8, 2018
cf695e3
Magic Modules changes.
Chupaka Nov 8, 2018
a84fb20
Magic Modules changes.
Chupaka Nov 10, 2018
395188f
Merge pull request #2430 from modular-magician/codegen-pr-882
chrisst Nov 8, 2018
cf4a2bf
make fmt
nat-henderson Dec 1, 2018
514e5c5
Fix disk snapshot expand/encode, kmsKeyName decoder (#2450)
modular-magician Nov 12, 2018
6abcee7
Update CHANGELOG.md
rileykarson Nov 12, 2018
efbbd79
Update CHANGELOG.md
rileykarson Nov 12, 2018
e7a6c8c
Merge pull request #2451 from modular-magician/codegen-pr-895
chrisst Nov 13, 2018
8d30cb1
Merge pull request #2452 from modular-magician/codegen-pr-896
chrisst Nov 13, 2018
50080d7
Update pubsub topic to read after create, same as TPG #2346 (#2469)
modular-magician Nov 13, 2018
ffb6ab3
Update CHANGELOG.md
danawillow Nov 13, 2018
b0c98fb
Add provider version to useragent. (#2442)
modular-magician Nov 14, 2018
bf2ca73
add warning about node pools defined in clusters. See TPG #1712. (#2474)
modular-magician Nov 14, 2018
a6e31f7
Add the sql ssl (client) cert resource (#2290)
benjvi Nov 14, 2018
1cc9b46
Update CHANGELOG.md
nat-henderson Dec 1, 2018
5e5c2c5
Update CHANGELOG.md
rileykarson Nov 16, 2018
4a4bb6d
Add new version + linker flags. (#2438)
rileykarson Nov 9, 2018
3e634af
Add weird diff to storage bucket docs. (#2470)
modular-magician Nov 14, 2018
d6d8085
Fix page title for SQL SSL Cert (#2487)
modular-magician Nov 16, 2018
14d0e52
Add billing account IAM (#2413)
modular-magician Nov 19, 2018
bb6e1c8
Update CHANGELOG.md
rileykarson Nov 19, 2018
9efa593
Add support for data source 'google_iam_role' (#2482)
manuelfelipe Nov 19, 2018
4270827
Update CHANGELOG.md
rileykarson Nov 19, 2018
2f63f81
Merge pull request #2533 from chrisst/monitoring-client
chrisst Nov 28, 2018
30a813a
Merge pull request #2502 from modular-magician/codegen-pr-933
chrisst Nov 28, 2018
f007f6d
Add support for content-based load balancing to google_compute_health…
modular-magician Nov 30, 2018
9e54630
Update CHANGELOG.md
rileykarson Nov 30, 2018
1b9a5d7
Update CHANGELOG.md
nat-henderson Dec 4, 2018
b954410
Add update_strategy deprecation message to 1.20.0. (#2575)
rileykarson Dec 5, 2018
30c3d00
Autogenerate {{Resource}}Destroy in tests. (#2317)
modular-magician Oct 26, 2018
9aefba4
Container cluster changes ancillary to beta support for autoprovision…
modular-magician Nov 15, 2018
47c5292
Compute project metadata reads were failing on import.
nat-henderson Dec 7, 2018
c5bd3a1
Add deprecation message to resource_google_project_iam_custom_role.de…
nat-henderson Dec 8, 2018
67527a3
Deprecate convenience fields in google_compute_snapshot (#2572)
modular-magician Dec 5, 2018
01e45c9
Update changelog.
nat-henderson Dec 11, 2018
8a67ec6
Fix nested read in Snapshot. (#2593)
modular-magician Dec 7, 2018
59bde74
Update our google.golang.org/api dependency.
paddycarver Nov 5, 2018
37d38de
Revert "Update our google.golang.org/api dependency."
paddycarver Nov 6, 2018
cef3918
Revert "Revert "Update our google.golang.org/api dependency.""
paddycarver Nov 15, 2018
59c9533
Fix the breaking change in sqladmin.
paddycarver Nov 19, 2018
025596e
Add router nat resource. For TPG #2249. (#2576)
modular-magician Dec 5, 2018
0b0f6fd
Add missing resources and datasources to sidebar. (#2381)
modular-magician Oct 31, 2018
2a96eab
Update CHANGELOG.md
rileykarson Dec 12, 2018
57062b9
Update CHANGELOG.md
nat-henderson Dec 12, 2018
b305551
formatting of CHANGELOG.
nat-henderson Dec 12, 2018
0fd99fc
Fix project services tests by using a service without any dependencie…
modular-magician Dec 12, 2018
3aff7f5
Fix for permadiff in container cluster caused by beta resource. (#2488)
modular-magician Nov 19, 2018
c6c8c47
Fix deprecated convenience fields in disk.
rileykarson Dec 5, 2018
3a8411f
Accommodate the new iamcredentials service in tests
paddycarver Dec 5, 2018
9e526a3
Fix project services tests by using a service without any dependencie…
modular-magician Dec 12, 2018
283a1e6
Fix spanner database iam binding import (#2603)
modular-magician Dec 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ GOOGLE_ORG
GOOGLE_BILLING_ACCOUNT
```

The only region we support running tests in right now is `us-central1` - some products that are tested here are only available in a few regions, and the only region that all products are available in is `us-central1`.

To run a specific test, use a command such as:
```
make testacc TEST=./google TESTARGS='-run=TestAccContainerNodePool_basic'
```

The `TESTARGS` variable is regexp-like, so multiple tests can be run in parallel by specifying a common substring of those tests (for example, `TestAccContainerNodePool` to run all node pool tests).

To run all tests, you can simply omit the `TESTARGS` argument - but please keep in mind that that is quite a few tests and will take quite a long time and create some fairly expensive resources. It usually is not advisable to run all tests.

### Writing Tests

Tests should confirm that a resource can be created, and that the resulting Terraform state has the correct values, as well as the created GCP resource.
Expand Down
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
## 1.19.2 (Unreleased)
## 1.20.0 (Unreleased)

DEPRECATIONS:
* **Deprecated `google_compute_snapshot`'s top-level encryption fields.** [GH-2572]

FEATURES:
nat-henderson marked this conversation as resolved.
Show resolved Hide resolved
* **New Resource**: `google_storage_object_access_control` for fine-grained management of ACLs on Google Cloud Storage objects [GH-2256]
* **New Resource**: `google_storage_default_object_access_control` for fine-grained management of default object ACLs on Google Cloud Storage buckets [GH-2358]
* **New Resource**: `google_sql_ssl_cert` for Google Cloud SQL client SSL certificates. [GH-2290]
* **New Resource**: `google_monitoring_notification_channel` [GH-2452]
* **New Resource**: `google_cloud_router_nat` [GH-2576]
* **New Resource**: `google_monitoring_group` [GH-2451]
* **New Resource**: `google_billing_account_iam_binding`, `google_billing_account_iam_member`, `google_billing_account_iam_policy` for managing Billing Account IAM policies, including managing Billing Account users. [GH-2143]
* **New Datasource**: `google_iam_role` datasource to be able to read an IAM role's permissions. [GH-2482]

ENHANCEMENTS:
* cloudbuild: Added Update support for `google_cloudbuild_trigger`. [GH-2121]
* cloudfunctions: Add `runtime` support to `google_cloudfunctions_function` [GH-2340]
* cloudfunctions: Add new-style Storage and Pub/Sub trigger support to `google_cloudfunctions_function` [GH-2412]
* compute: `google_compute_health_check` supports for content-based load balancing (`response` field) in HTTP(S) checks. [GH-2550]
* container: regional and private clusters are in GA now [GH-2364]
* iam: `google_service_accounts` now supports multiple import formats. [GH-2261]

BUG FIXES:
* bigquery: added australia and europe regions to the validate function [GH-2333]
* compute: `google_compute_disk.snapshot`, `google_compute_region_disk.snapshot` properly allow partial URIs. [GH-2450]
* pubsub: fix issue where not all attributes were saved in state [GH-2469]

## 1.19.1 (October 12, 2018)

BUG FIXES:
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test: fmtcheck
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc: fmtcheck
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc"

vet:
@echo "go vet ."
Expand Down
10 changes: 6 additions & 4 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/helper/pathorcontents"
"github.com/hashicorp/terraform/version"
"github.com/hashicorp/terraform/httpclient"
"github.com/terraform-providers/terraform-provider-google/version"

"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
Expand Down Expand Up @@ -154,9 +155,10 @@ func (c *Config) loadAndValidate() error {

client.Transport = logging.NewTransport("Google", client.Transport)

projectURL := "https://www.terraform.io"
userAgent := fmt.Sprintf("Terraform/%s (+%s)",
version.String(), projectURL)
terraformVersion := httpclient.UserAgentString()
providerVersion := fmt.Sprintf("terraform-provider-google/%s", version.ProviderVersion)
terraformWebsite := "(+https://www.terraform.io)"
userAgent := fmt.Sprintf("%s %s %s", terraformVersion, terraformWebsite, providerVersion)

c.client = client
c.userAgent = userAgent
Expand Down
1 change: 0 additions & 1 deletion google/data_source_google_container_engine_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func dataSourceGoogleContainerEngineVersions() *schema.Resource {
Optional: true,
},
"region": {
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"zone"},
Expand Down
48 changes: 48 additions & 0 deletions google/data_source_google_iam_role.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package google

import (
"fmt"

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

func dataSourceGoogleIamRole() *schema.Resource {
return &schema.Resource{
Read: dataSourceGoogleIamRoleRead,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"title": {
Type: schema.TypeString,
Computed: true,
},
"included_permissions": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"stage": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func dataSourceGoogleIamRoleRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
roleName := d.Get("name").(string)
role, err := config.clientIAM.Roles.Get(roleName).Do()
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("Error reading IAM Role %s: %s", roleName, err))
}

d.SetId(role.Name)
d.Set("title", role.Title)
d.Set("stage", role.Stage)
d.Set("included_permissions", role.IncludedPermissions)

return nil
}
51 changes: 51 additions & 0 deletions google/data_source_google_iam_role_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package google

import (
"errors"
"fmt"
"testing"

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

func TestAccDataSourceIAMRole(t *testing.T) {
name := "roles/viewer"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckGoogleIamRoleConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckGoogleIAMRoleCheck("data.google_iam_role.role"),
),
},
},
})
}

func testAccCheckGoogleIAMRoleCheck(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
ds, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Can't find iam role data source: %s", n)
}

_, ok = ds.Primary.Attributes["included_permissions.#"]
if !ok {
return errors.New("can't find 'included_permissions' attribute")
}

return nil
}
}

func testAccCheckGoogleIamRoleConfig(name string) string {
return fmt.Sprintf(`
data "google_iam_role" "role" {
name = "%s"
}
`, name)
}
105 changes: 105 additions & 0 deletions google/iam_billing_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package google

import (
"fmt"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/cloudbilling/v1"
"google.golang.org/api/cloudresourcemanager/v1"
)

var IamBillingAccountSchema = map[string]*schema.Schema{
"billing_account_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
}

type BillingAccountIamUpdater struct {
billingAccountId string
Config *Config
}

func NewBillingAccountIamUpdater(d *schema.ResourceData, config *Config) (ResourceIamUpdater, error) {
return &BillingAccountIamUpdater{
billingAccountId: canonicalBillingAccountId(d.Get("billing_account_id").(string)),
Config: config,
}, nil
}

func BillingAccountIdParseFunc(d *schema.ResourceData, _ *Config) error {
d.Set("billing_account_id", d.Id())
return nil
}

func (u *BillingAccountIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) {
return getBillingAccountIamPolicyByBillingAccountName(u.billingAccountId, u.Config)
}

func (u *BillingAccountIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error {
billingPolicy, err := resourceManagerToBillingPolicy(policy)
if err != nil {
return err
}

_, err = u.Config.clientBilling.BillingAccounts.SetIamPolicy("billingAccounts/"+u.billingAccountId, &cloudbilling.SetIamPolicyRequest{
Policy: billingPolicy,
}).Do()

if err != nil {
return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err)
}

return nil
}

func (u *BillingAccountIamUpdater) GetResourceId() string {
return u.billingAccountId
}

func (u *BillingAccountIamUpdater) GetMutexKey() string {
return fmt.Sprintf("iam-billing-account-%s", u.billingAccountId)
}

func (u *BillingAccountIamUpdater) DescribeResource() string {
return fmt.Sprintf("billingAccount %q", u.billingAccountId)
}

func canonicalBillingAccountId(resource string) string {
return resource
}

func resourceManagerToBillingPolicy(p *cloudresourcemanager.Policy) (*cloudbilling.Policy, error) {
out := &cloudbilling.Policy{}
err := Convert(p, out)
if err != nil {
return nil, errwrap.Wrapf("Cannot convert a v1 policy to a billing policy: {{err}}", err)
}
return out, nil
}

func billingToResourceManagerPolicy(p *cloudbilling.Policy) (*cloudresourcemanager.Policy, error) {
out := &cloudresourcemanager.Policy{}
err := Convert(p, out)
if err != nil {
return nil, errwrap.Wrapf("Cannot convert a billing policy to a v1 policy: {{err}}", err)
}
return out, nil
}

// Retrieve the existing IAM Policy for a billing account
func getBillingAccountIamPolicyByBillingAccountName(resource string, config *Config) (*cloudresourcemanager.Policy, error) {
p, err := config.clientBilling.BillingAccounts.GetIamPolicy("billingAccounts/" + resource).Do()

if err != nil {
return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for billing account %q: {{err}}", resource), err)
}

v1Policy, err := billingToResourceManagerPolicy(p)
if err != nil {
return nil, err
}

return v1Policy, nil
}
6 changes: 3 additions & 3 deletions google/iam_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import (

var IamComputeSubnetworkSchema = map[string]*schema.Schema{
"subnetwork": {
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like #2271 did this, and this was the final state of the file at HEAD in 2.0.0. It was then removed (#2398). The "resource" text would be preferred here though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm agreed on the resource text being preferred here, but don't know how possible that is.

Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"project": {
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},

"region": {
Deprecated: "This resource is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Deprecated: "This field is in beta and will be removed from this provider. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
Type: schema.TypeString,
Optional: true,
Computed: true,
Expand Down
15 changes: 3 additions & 12 deletions google/iam_spanner_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/cloudresourcemanager/v1"
spanner "google.golang.org/api/spanner/v1"
"google.golang.org/api/spanner/v1"
)

var IamSpannerDatabaseSchema = map[string]*schema.Schema{
Expand Down Expand Up @@ -51,17 +51,8 @@ func NewSpannerDatabaseIamUpdater(d *schema.ResourceData, config *Config) (Resou
}

func SpannerDatabaseIdParseFunc(d *schema.ResourceData, config *Config) error {
id, err := extractSpannerDatabaseId(d.Id())
if err != nil {
return err
}
d.Set("instance", id.Instance)
d.Set("project", id.Project)
d.Set("database", id.Database)

// Explicitly set the id so imported resources have the same ID format as non-imported ones.
d.SetId(id.terraformId())
return nil
_, err := resourceSpannerDatabaseImport("database")(d, config)
return err
}

func (u *SpannerDatabaseIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) {
Expand Down
Loading