-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling Membership resource to be regionalized with global as defaul…
…t value (#8994) * Adding Terraform resources for Tenancy APIs in GKEHub * Segregating MembershipBinding and MembershipRBACRoleBinding to keep things simpler in the review * Fixing the docu URIs * Adding TF support for Tenancy API for Membership Binding * Adding dependent membership binding to the same commit chain * Making Scope un-updatable and replacing hard coded project number with the one from test env * Making Scope RRBAC updatable * Making Namespace immutable * Adding update test cases * Removing all memberships field from Scope since it is no longer supported * Removing all_memberships field for Scope from all test cases * Enabling Membership resource to be regionalized with global as default value * Moving the test to be the first one in sequence to work-around the IAM test failure * Update mmv1/products/gkehub/Membership.yaml Co-authored-by: Stephen Lewis (Burrows) <[email protected]> * Adding state migration for gke hub membership * Update mmv1/templates/terraform/examples/gkehub_membership_regional.tf.erb Co-authored-by: Stephen Lewis (Burrows) <[email protected]> --------- Co-authored-by: Stephen Lewis (Burrows) <[email protected]> [upstream:bf6b0ee32b7b469a27b4595c695619dcc9f0de5b] Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
d7e7482
commit a241f0e
Showing
8 changed files
with
271 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
```release-note:enhancement | ||
gkehub: added `location` field to `google_gke_hub_membership` resource | ||
``` | ||
```release-note:enhancement | ||
gkehub: added `location` field to `google_gke_hub_membership_iam_*` resources | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,10 @@ func TestAccGKEHubMembershipIamBindingGenerated(t *testing.T) { | |
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
"role": "roles/viewer", | ||
"deletion_protection": false, | ||
"random_suffix": acctest.RandString(t, 10), | ||
"role": "roles/viewer", | ||
"project": envvar.GetTestProjectFromEnv(), | ||
"location": envvar.GetTestRegionFromEnv(), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
|
@@ -67,9 +68,10 @@ func TestAccGKEHubMembershipIamMemberGenerated(t *testing.T) { | |
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
"role": "roles/viewer", | ||
"deletion_protection": false, | ||
"random_suffix": acctest.RandString(t, 10), | ||
"role": "roles/viewer", | ||
"project": envvar.GetTestProjectFromEnv(), | ||
"location": envvar.GetTestRegionFromEnv(), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
|
@@ -94,9 +96,10 @@ func TestAccGKEHubMembershipIamPolicyGenerated(t *testing.T) { | |
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
"role": "roles/viewer", | ||
"deletion_protection": false, | ||
"random_suffix": acctest.RandString(t, 10), | ||
"role": "roles/viewer", | ||
"project": envvar.GetTestProjectFromEnv(), | ||
"location": envvar.GetTestRegionFromEnv(), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
|
@@ -132,24 +135,22 @@ resource "google_container_cluster" "primary" { | |
name = "basiccluster%{random_suffix}" | ||
location = "us-central1-a" | ||
initial_node_count = 1 | ||
deletion_protection = "%{deletion_protection}" | ||
deletion_protection = false | ||
} | ||
resource "google_gke_hub_membership" "membership" { | ||
membership_id = "basic%{random_suffix}" | ||
location = "%{location}" | ||
endpoint { | ||
gke_cluster { | ||
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}" | ||
} | ||
} | ||
labels = { | ||
env = "test" | ||
} | ||
} | ||
resource "google_gke_hub_membership_iam_member" "foo" { | ||
project = google_gke_hub_membership.membership.project | ||
location = google_gke_hub_membership.membership.location | ||
membership_id = google_gke_hub_membership.membership.membership_id | ||
role = "%{role}" | ||
member = "user:[email protected]" | ||
|
@@ -163,20 +164,17 @@ resource "google_container_cluster" "primary" { | |
name = "basiccluster%{random_suffix}" | ||
location = "us-central1-a" | ||
initial_node_count = 1 | ||
deletion_protection = "%{deletion_protection}" | ||
deletion_protection = false | ||
} | ||
resource "google_gke_hub_membership" "membership" { | ||
membership_id = "basic%{random_suffix}" | ||
location = "%{location}" | ||
endpoint { | ||
gke_cluster { | ||
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}" | ||
} | ||
} | ||
labels = { | ||
env = "test" | ||
} | ||
} | ||
data "google_iam_policy" "foo" { | ||
|
@@ -188,12 +186,14 @@ data "google_iam_policy" "foo" { | |
resource "google_gke_hub_membership_iam_policy" "foo" { | ||
project = google_gke_hub_membership.membership.project | ||
location = google_gke_hub_membership.membership.location | ||
membership_id = google_gke_hub_membership.membership.membership_id | ||
policy_data = data.google_iam_policy.foo.policy_data | ||
} | ||
data "google_gke_hub_membership_iam_policy" "foo" { | ||
project = google_gke_hub_membership.membership.project | ||
location = google_gke_hub_membership.membership.location | ||
membership_id = google_gke_hub_membership.membership.membership_id | ||
depends_on = [ | ||
google_gke_hub_membership_iam_policy.foo | ||
|
@@ -208,27 +208,25 @@ resource "google_container_cluster" "primary" { | |
name = "basiccluster%{random_suffix}" | ||
location = "us-central1-a" | ||
initial_node_count = 1 | ||
deletion_protection = "%{deletion_protection}" | ||
deletion_protection = false | ||
} | ||
resource "google_gke_hub_membership" "membership" { | ||
membership_id = "basic%{random_suffix}" | ||
location = "%{location}" | ||
endpoint { | ||
gke_cluster { | ||
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}" | ||
} | ||
} | ||
labels = { | ||
env = "test" | ||
} | ||
} | ||
data "google_iam_policy" "foo" { | ||
} | ||
resource "google_gke_hub_membership_iam_policy" "foo" { | ||
project = google_gke_hub_membership.membership.project | ||
location = google_gke_hub_membership.membership.location | ||
membership_id = google_gke_hub_membership.membership.membership_id | ||
policy_data = data.google_iam_policy.foo.policy_data | ||
} | ||
|
@@ -241,24 +239,22 @@ resource "google_container_cluster" "primary" { | |
name = "basiccluster%{random_suffix}" | ||
location = "us-central1-a" | ||
initial_node_count = 1 | ||
deletion_protection = "%{deletion_protection}" | ||
deletion_protection = false | ||
} | ||
resource "google_gke_hub_membership" "membership" { | ||
membership_id = "basic%{random_suffix}" | ||
location = "%{location}" | ||
endpoint { | ||
gke_cluster { | ||
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}" | ||
} | ||
} | ||
labels = { | ||
env = "test" | ||
} | ||
} | ||
resource "google_gke_hub_membership_iam_binding" "foo" { | ||
project = google_gke_hub_membership.membership.project | ||
location = google_gke_hub_membership.membership.location | ||
membership_id = google_gke_hub_membership.membership.membership_id | ||
role = "%{role}" | ||
members = ["user:[email protected]"] | ||
|
@@ -272,24 +268,22 @@ resource "google_container_cluster" "primary" { | |
name = "basiccluster%{random_suffix}" | ||
location = "us-central1-a" | ||
initial_node_count = 1 | ||
deletion_protection = "%{deletion_protection}" | ||
deletion_protection = false | ||
} | ||
resource "google_gke_hub_membership" "membership" { | ||
membership_id = "basic%{random_suffix}" | ||
location = "%{location}" | ||
endpoint { | ||
gke_cluster { | ||
resource_link = "//container.googleapis.com/${google_container_cluster.primary.id}" | ||
} | ||
} | ||
labels = { | ||
env = "test" | ||
} | ||
} | ||
resource "google_gke_hub_membership_iam_binding" "foo" { | ||
project = google_gke_hub_membership.membership.project | ||
location = google_gke_hub_membership.membership.location | ||
membership_id = google_gke_hub_membership.membership.membership_id | ||
role = "%{role}" | ||
members = ["user:[email protected]", "user:[email protected]"] | ||
|
Oops, something went wrong.