blob: 11eec12370ade0f7c19ea33b9b7ae911be724181 [file] [log] [blame]
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package notebooks_test
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar"
)
func TestAccNotebooksRuntimeIamBindingGenerated(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"role": "roles/viewer",
}
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccNotebooksRuntimeIamBinding_basicGenerated(context),
},
{
ResourceName: "google_notebooks_runtime_iam_binding.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/runtimes/%s roles/viewer", envvar.GetTestProjectFromEnv(), "us-central1", fmt.Sprintf("tf-test-notebooks-runtime%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
{
// Test Iam Binding update
Config: testAccNotebooksRuntimeIamBinding_updateGenerated(context),
},
{
ResourceName: "google_notebooks_runtime_iam_binding.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/runtimes/%s roles/viewer", envvar.GetTestProjectFromEnv(), "us-central1", fmt.Sprintf("tf-test-notebooks-runtime%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func TestAccNotebooksRuntimeIamMemberGenerated(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"role": "roles/viewer",
}
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
// Test Iam Member creation (no update for member, no need to test)
Config: testAccNotebooksRuntimeIamMember_basicGenerated(context),
},
{
ResourceName: "google_notebooks_runtime_iam_member.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/runtimes/%s roles/viewer user:admin@hashicorptest.com", envvar.GetTestProjectFromEnv(), "us-central1", fmt.Sprintf("tf-test-notebooks-runtime%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func TestAccNotebooksRuntimeIamPolicyGenerated(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"role": "roles/viewer",
}
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccNotebooksRuntimeIamPolicy_basicGenerated(context),
Check: resource.TestCheckResourceAttrSet("data.google_notebooks_runtime_iam_policy.foo", "policy_data"),
},
{
ResourceName: "google_notebooks_runtime_iam_policy.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/runtimes/%s", envvar.GetTestProjectFromEnv(), "us-central1", fmt.Sprintf("tf-test-notebooks-runtime%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccNotebooksRuntimeIamPolicy_emptyBinding(context),
},
{
ResourceName: "google_notebooks_runtime_iam_policy.foo",
ImportStateId: fmt.Sprintf("projects/%s/locations/%s/runtimes/%s", envvar.GetTestProjectFromEnv(), "us-central1", fmt.Sprintf("tf-test-notebooks-runtime%s", context["random_suffix"])),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccNotebooksRuntimeIamMember_basicGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "admin@hashicorptest.com"
}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
}
}
}
resource "google_notebooks_runtime_iam_member" "foo" {
project = google_notebooks_runtime.runtime.project
location = google_notebooks_runtime.runtime.location
runtime_name = google_notebooks_runtime.runtime.name
role = "%{role}"
member = "user:admin@hashicorptest.com"
}
`, context)
}
func testAccNotebooksRuntimeIamPolicy_basicGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "admin@hashicorptest.com"
}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
}
}
}
data "google_iam_policy" "foo" {
binding {
role = "%{role}"
members = ["user:admin@hashicorptest.com"]
}
}
resource "google_notebooks_runtime_iam_policy" "foo" {
project = google_notebooks_runtime.runtime.project
location = google_notebooks_runtime.runtime.location
runtime_name = google_notebooks_runtime.runtime.name
policy_data = data.google_iam_policy.foo.policy_data
}
data "google_notebooks_runtime_iam_policy" "foo" {
project = google_notebooks_runtime.runtime.project
location = google_notebooks_runtime.runtime.location
runtime_name = google_notebooks_runtime.runtime.name
depends_on = [
google_notebooks_runtime_iam_policy.foo
]
}
`, context)
}
func testAccNotebooksRuntimeIamPolicy_emptyBinding(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "admin@hashicorptest.com"
}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
}
}
}
data "google_iam_policy" "foo" {
}
resource "google_notebooks_runtime_iam_policy" "foo" {
project = google_notebooks_runtime.runtime.project
location = google_notebooks_runtime.runtime.location
runtime_name = google_notebooks_runtime.runtime.name
policy_data = data.google_iam_policy.foo.policy_data
}
`, context)
}
func testAccNotebooksRuntimeIamBinding_basicGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "admin@hashicorptest.com"
}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
}
}
}
resource "google_notebooks_runtime_iam_binding" "foo" {
project = google_notebooks_runtime.runtime.project
location = google_notebooks_runtime.runtime.location
runtime_name = google_notebooks_runtime.runtime.name
role = "%{role}"
members = ["user:admin@hashicorptest.com"]
}
`, context)
}
func testAccNotebooksRuntimeIamBinding_updateGenerated(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "admin@hashicorptest.com"
}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
}
}
}
resource "google_notebooks_runtime_iam_binding" "foo" {
project = google_notebooks_runtime.runtime.project
location = google_notebooks_runtime.runtime.location
runtime_name = google_notebooks_runtime.runtime.name
role = "%{role}"
members = ["user:admin@hashicorptest.com", "user:gterraformtest1@gmail.com"]
}
`, context)
}