Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interconnect immutability issue causing macsec failure #11700

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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)
}
Loading