Skip to content

Commit

Permalink
make immutability granular by removing it on the whole resource
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithpatte-g committed Sep 13, 2024
1 parent fd83651 commit e726000
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mmv1/products/compute/Interconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/interconnects'
base_url: 'projects/{{project}}/global/interconnects'
self_link: 'projects/{{project}}/global/interconnects/{{name}}'
immutable: true
update_verb: :PATCH
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
kind: 'compute#operation'
Expand Down Expand Up @@ -366,11 +366,13 @@ properties:
MACsec enablement fails if the MACsec object is not specified.
- !ruby/object:Api::Type::String
name: 'remoteLocation'
immutable: true
description: |
Indicates that this is a Cross-Cloud Interconnect. This field specifies the location outside
of Google's network that the interconnect is connected to.
- !ruby/object:Api::Type::Array
name: 'requestedFeatures'
immutable: true
description: |
interconnects.list of features requested for this Interconnect connection. Options: IF_MACSEC (
If specified then the connection is created on MACsec capable hardware ports. If not
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package compute_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"

"github.com/hashicorp/terraform-provider-google/google/acctest"
)

func TestAccComputeInterconnect_computeInterconnectMacsecTest(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeInterconnectDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeInterconnect_computeInterconnectCreate(context),
},
{
ResourceName: "google_compute_interconnect.example-interconnect",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "location", "terraform_labels"},
},
{
Config: testAccComputeInterconnect_computeInterconnectEnableMacsec(context),
},
{
ResourceName: "google_compute_interconnect.example-interconnect",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "location", "terraform_labels"},
},
},
})
}

func testAccComputeInterconnect_computeInterconnectCreate(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "project" {}
resource "google_compute_interconnect" "example-interconnect" {
name = "tf-test-example-interconnect%{random_suffix}"
customer_name = "internal_customer" # Special customer only available for Google testing.
interconnect_type = "DEDICATED"
link_type = "LINK_TYPE_ETHERNET_100G_LR"
location = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.name}/global/interconnectLocations/z2z-us-east4-zone1-lciadl-a" # Special location only available for Google testing.
requested_link_count = 1
admin_enabled = true
description = "example description"
macsec_enabled = false
noc_contact_email = "[email protected]"
requested_features = ["IF_MACSEC"]
}
`, context)
}

func testAccComputeInterconnect_computeInterconnectEnableMacsec(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "project" {}
resource "google_compute_interconnect" "example-interconnect" {
name = "tf-test-example-interconnect%{random_suffix}"
customer_name = "internal_customer" # Special customer only available for Google testing.
interconnect_type = "DEDICATED"
link_type = "LINK_TYPE_ETHERNET_100G_LR"
location = "https://www.googleapis.com/compute/v1/projects/${data.google_project.project.name}/global/interconnectLocations/z2z-us-east4-zone1-lciadl-a" # Special location only available for Google testing.
requested_link_count = 1
admin_enabled = true
description = "example description"
macsec_enabled = true
noc_contact_email = "[email protected]"
requested_features = ["IF_MACSEC"]
macsec {
pre_shared_keys {
name = "test-key"
start_time = "2023-07-01T21:00:01.000Z"
fail_open = true
}
}
}
`, context)
}

0 comments on commit e726000

Please sign in to comment.