Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/hashicorp/hcl/v2 v2.24.0
github.com/hashicorp/terraform-json v0.27.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20260108195301-1a2fde7e0903
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20260108213040-e042301c29c4
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.11.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1w
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU=
github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c=
github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20260108195301-1a2fde7e0903 h1:HeEL+VQnukXhgG1Idivi3om4eQSm84mJP3u7q5qPDf0=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20260108195301-1a2fde7e0903/go.mod h1:8eg1tVfOJEzN2+inar3phK3XurwWzQq1O/6LsGlTZ7w=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20260108213040-e042301c29c4 h1:CKSdvls8BhDCXtt+slxyh6ubzCQ1d96tJjDUxCQD2Qo=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20260108213040-e042301c29c4/go.mod h1:8eg1tVfOJEzN2+inar3phK3XurwWzQq1O/6LsGlTZ7w=
github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk=
github.com/hashicorp/terraform-registry-address v0.4.0/go.mod h1:LRS1Ay0+mAiRkUyltGT+UHWkIqTFvigGn/LbMshfflE=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
20 changes: 17 additions & 3 deletions pkg/services/workbench/workbench_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ var WorkbenchInstanceSettableUnmodifiableDefaultMetadata = []string{
"report-notebook-metrics",
}

var WorkbenchInstanceEUCSettableUnmodifiableDefaultMetadata = []string{
"post-startup-script",
"post-startup-script-behavior",
}

var WorkbenchInstanceEUCProvidedAdditionalMetadata = []string{
"enable-oslogin",
"disable-ssh",
"ssh-keys",
"block-project-ssh-keys",
"post-startup-script",
"post-startup-script-behavior",
"startup-script",
"startup-script-url",
"gce-container-declaration",
Expand Down Expand Up @@ -134,6 +137,12 @@ func WorkbenchInstanceMetadataDiffSuppress(k, old, new string, d *schema.Resourc
return true
}
}

for _, metadata := range WorkbenchInstanceEUCSettableUnmodifiableDefaultMetadata {
if key == metadata && new == "" {
return true
}
}
}

for _, metadata := range WorkbenchInstanceSettableUnmodifiableDefaultMetadata {
Expand Down Expand Up @@ -222,7 +231,12 @@ func workbenchMetadataCustomizeDiff(_ context.Context, diff *schema.ResourceDiff
oldMetadata := o.(map[string]interface{})
newMetadata := n.(map[string]interface{})

for _, key := range WorkbenchInstanceSettableUnmodifiableDefaultMetadata {
unmodifiableKeys := append([]string{}, WorkbenchInstanceSettableUnmodifiableDefaultMetadata...)
if v, ok := diff.GetOk("enable_managed_euc"); ok && v.(bool) {
unmodifiableKeys = append(unmodifiableKeys, WorkbenchInstanceEUCSettableUnmodifiableDefaultMetadata...)
}

for _, key := range unmodifiableKeys {
oldValue, oldOk := oldMetadata[key]
newValue, newOk := newMetadata[key]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func TestAccWorkbenchInstance(t *testing.T) {
{
Name: "TestAccWorkbenchInstance_updateCustomContainers",
},
{
Name: "TestAccWorkbenchInstance_metadataEUCForceNew",
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ var WorkbenchInstanceSettableUnmodifiableDefaultMetadata = []string{
"report-notebook-metrics",
}

var WorkbenchInstanceEUCSettableUnmodifiableDefaultMetadata = []string{
"post-startup-script",
"post-startup-script-behavior",
}

var WorkbenchInstanceEUCProvidedAdditionalMetadata = []string{
"enable-oslogin",
"disable-ssh",
"ssh-keys",
"block-project-ssh-keys",
"post-startup-script",
"post-startup-script-behavior",
"startup-script",
"startup-script-url",
"gce-container-declaration",
Expand Down Expand Up @@ -146,6 +149,12 @@ func WorkbenchInstanceMetadataDiffSuppress(k, old, new string, d *schema.Resourc
return true
}
}

for _, metadata := range WorkbenchInstanceEUCSettableUnmodifiableDefaultMetadata {
if key == metadata && new == "" {
return true
}
}
}

for _, metadata := range WorkbenchInstanceSettableUnmodifiableDefaultMetadata {
Expand Down Expand Up @@ -234,7 +243,12 @@ func workbenchMetadataCustomizeDiff(_ context.Context, diff *schema.ResourceDiff
oldMetadata := o.(map[string]interface{})
newMetadata := n.(map[string]interface{})

for _, key := range WorkbenchInstanceSettableUnmodifiableDefaultMetadata {
unmodifiableKeys := append([]string{}, WorkbenchInstanceSettableUnmodifiableDefaultMetadata...)
if v, ok := diff.GetOk("enable_managed_euc"); ok && v.(bool) {
unmodifiableKeys = append(unmodifiableKeys, WorkbenchInstanceEUCSettableUnmodifiableDefaultMetadata...)
}

for _, key := range unmodifiableKeys {
oldValue, oldOk := oldMetadata[key]
newValue, newOk := newMetadata[key]

Expand Down