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

Add MTU to interconnect #3006

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
3 changes: 3 additions & 0 deletions .changelog/4496.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `mtu` field to `google_compute_interconnect_attachment`
```
30 changes: 30 additions & 0 deletions google-beta/resource_compute_interconnect_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ domain. If not specified, the value will default to AVAILABILITY_DOMAIN_ANY.`,
Description: `URL of the underlying Interconnect object that this attachment's
traffic will traverse through. Required if type is DEDICATED, must not
be set if type is PARTNER.`,
},
"mtu": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `Maximum Transmission Unit (MTU), in bytes, of packets passing through
this interconnect attachment. Currently, only 1440 and 1500 are allowed. If not specified, the value will default to 1440.`,
},
"region": {
Type: schema.TypeString,
Expand Down Expand Up @@ -267,6 +274,12 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
mtuProp, err := expandComputeInterconnectAttachmentMtu(d.Get("mtu"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("mtu"); !isEmptyValue(reflect.ValueOf(mtuProp)) && (ok || !reflect.DeepEqual(v, mtuProp)) {
obj["mtu"] = mtuProp
}
bandwidthProp, err := expandComputeInterconnectAttachmentBandwidth(d.Get("bandwidth"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -415,6 +428,9 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
if err := d.Set("description", flattenComputeInterconnectAttachmentDescription(res["description"], d, config)); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
if err := d.Set("mtu", flattenComputeInterconnectAttachmentMtu(res["mtu"], d, config)); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
if err := d.Set("bandwidth", flattenComputeInterconnectAttachmentBandwidth(res["bandwidth"], d, config)); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
Expand Down Expand Up @@ -489,6 +505,12 @@ func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta in
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
mtuProp, err := expandComputeInterconnectAttachmentMtu(d.Get("mtu"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("mtu"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, mtuProp)) {
obj["mtu"] = mtuProp
}
bandwidthProp, err := expandComputeInterconnectAttachmentBandwidth(d.Get("bandwidth"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -622,6 +644,10 @@ func flattenComputeInterconnectAttachmentDescription(v interface{}, d *schema.Re
return v
}

func flattenComputeInterconnectAttachmentMtu(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenComputeInterconnectAttachmentBandwidth(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}
Expand Down Expand Up @@ -731,6 +757,10 @@ func expandComputeInterconnectAttachmentDescription(v interface{}, d TerraformRe
return v, nil
}

func expandComputeInterconnectAttachmentMtu(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeInterconnectAttachmentBandwidth(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/compute_interconnect_attachment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ resource "google_compute_interconnect_attachment" "on_prem" {
name = "on-prem-attachment"
interconnect = "my-interconnect-id"
router = google_compute_router.foobar.id
mtu = 1500
}

resource "google_compute_router" "foobar" {
Expand Down Expand Up @@ -83,6 +84,11 @@ The following arguments are supported:
(Optional)
An optional description of this resource.

* `mtu` -
(Optional)
Maximum Transmission Unit (MTU), in bytes, of packets passing through
this interconnect attachment. Currently, only 1440 and 1500 are allowed. If not specified, the value will default to 1440.

* `bandwidth` -
(Optional)
Provisioned bandwidth capacity for the interconnect attachment.
Expand Down