-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cloud Workstations - Workstation (#7018)
- Loading branch information
1 parent
16ec6e9
commit 75c90f6
Showing
4 changed files
with
322 additions
and
2 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
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
60 changes: 60 additions & 0 deletions
60
mmv1/templates/terraform/examples/workstation_basic.tf.erb
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,60 @@ | ||
resource "google_compute_network" "default" { | ||
provider = google-beta | ||
name = "<%= ctx[:vars]['workstation_cluster_name'] %>" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
resource "google_compute_subnetwork" "default" { | ||
provider = google-beta | ||
name = "<%= ctx[:vars]['workstation_cluster_name'] %>" | ||
ip_cidr_range = "10.0.0.0/24" | ||
region = "us-central1" | ||
network = google_compute_network.default.name | ||
} | ||
|
||
resource "google_workstations_workstation_cluster" "<%= ctx[:primary_resource_id] %>" { | ||
provider = google-beta | ||
workstation_cluster_id = "<%= ctx[:vars]['workstation_cluster_name'] %>" | ||
network = google_compute_network.default.id | ||
subnetwork = google_compute_subnetwork.default.id | ||
location = "us-central1" | ||
|
||
labels = { | ||
"label" = "key" | ||
} | ||
|
||
annotations = { | ||
label-one = "value-one" | ||
} | ||
} | ||
|
||
resource "google_workstations_workstation_config" "<%= ctx[:primary_resource_id] %>" { | ||
provider = google-beta | ||
workstation_config_id = "<%= ctx[:vars]['workstation_config_name'] %>" | ||
workstation_cluster_id = google_workstations_workstation_cluster.<%= ctx[:primary_resource_id] %>.workstation_cluster_id | ||
location = "us-central1" | ||
|
||
host { | ||
gce_instance { | ||
machine_type = "e2-standard-4" | ||
boot_disk_size_gb = 35 | ||
disable_public_ip_addresses = true | ||
} | ||
} | ||
} | ||
|
||
resource "google_workstations_workstation" "<%= ctx[:primary_resource_id] %>" { | ||
provider = google-beta | ||
workstation_id = "<%= ctx[:vars]['workstation_name'] %>" | ||
workstation_config_id = google_workstations_workstation_config.<%= ctx[:primary_resource_id] %>.workstation_config_id | ||
workstation_cluster_id = google_workstations_workstation_cluster.<%= ctx[:primary_resource_id] %>.workstation_cluster_id | ||
location = "us-central1" | ||
|
||
labels = { | ||
"label" = "key" | ||
} | ||
|
||
annotations = { | ||
label-one = "value-one" | ||
} | ||
} |
142 changes: 142 additions & 0 deletions
142
mmv1/third_party/terraform/tests/resource_workstations_workstation_test.go.erb
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,142 @@ | ||
<% autogen_exception -%> | ||
package google | ||
<% unless version == "ga" -%> | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccWorkstationsWorkstation_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": randString(t, 10), | ||
} | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckWorkstationsWorkstationDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccWorkstationsWorkstation_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_workstations_workstation_cluster.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"etag"}, | ||
}, | ||
{ | ||
Config: testAccWorkstationsWorkstation_modified(context), | ||
}, | ||
{ | ||
ResourceName: "google_workstations_workstation_cluster.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"etag"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
|
||
func testAccWorkstationsWorkstation_basic(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_compute_network" "default" { | ||
name = "tf-test-workstation-cluster%{random_suffix}" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
resource "google_compute_subnetwork" "default" { | ||
name = "tf-test-workstation-cluster%{random_suffix}" | ||
ip_cidr_range = "10.0.0.0/24" | ||
region = "us-central1" | ||
network = google_compute_network.default.name | ||
} | ||
|
||
resource "google_workstations_workstation_cluster" "default" { | ||
workstation_cluster_id = "tf-test-workstation-cluster%{random_suffix}" | ||
network = google_compute_network.default.id | ||
subnetwork = google_compute_subnetwork.default.id | ||
location = "us-central1" | ||
|
||
labels = { | ||
foo = "bar" | ||
} | ||
} | ||
|
||
resource "google_workstations_workstation_config" "default" { | ||
workstation_config_id = "tf-test-workstation-config%{random_suffix}" | ||
workstation_cluster_id = google_workstations_workstation_cluster.default.workstation_cluster_id | ||
location = "us-central1" | ||
|
||
labels = { | ||
foo = "bar" | ||
} | ||
} | ||
|
||
resource "google_workstations_workstation" "default" { | ||
workstation_id = "tf-test-workstation%{random_suffix}" | ||
workstation_config_id = google_workstations_workstation_config.default.workstation_config_id | ||
workstation_cluster_id = google_workstations_workstation_cluster.default.workstation_cluster_id | ||
location = "us-central1" | ||
|
||
labels = { | ||
foo = "bar" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccWorkstationsWorkstation_modified(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_compute_network" "default" { | ||
name = "tf-test-workstation-cluster%{random_suffix}" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
resource "google_compute_subnetwork" "default" { | ||
name = "tf-test-workstation-cluster%{random_suffix}" | ||
ip_cidr_range = "10.0.0.0/24" | ||
region = "us-central1" | ||
network = google_compute_network.default.name | ||
} | ||
|
||
resource "google_workstations_workstation_cluster" "default" { | ||
workstation_cluster_id = "tf-test-workstation-cluster%{random_suffix}" | ||
network = google_compute_network.default.id | ||
subnetwork = google_compute_subnetwork.default.id | ||
location = "us-central1" | ||
|
||
labels = { | ||
foo = "bar" | ||
} | ||
} | ||
|
||
resource "google_workstations_workstation_config" "default" { | ||
workstation_config_id = "tf-test-workstation-config%{random_suffix}" | ||
workstation_cluster_id = google_workstations_workstation_cluster.default.workstation_cluster_id | ||
location = "us-central1" | ||
|
||
labels = { | ||
foo = "bar" | ||
} | ||
} | ||
|
||
resource "google_workstations_workstation" "default" { | ||
workstation_id = "tf-test-workstation%{random_suffix}" | ||
workstation_config_id = google_workstations_workstation_config.default.workstation_config_id | ||
workstation_cluster_id = google_workstations_workstation_cluster.default.workstation_cluster_id | ||
location = "us-central1" | ||
display_name = "workstation%{random_suffix}" | ||
|
||
labels = { | ||
foo = "bar" | ||
} | ||
} | ||
`, context) | ||
} | ||
<% end -%> |