From 53b60e1cc129e729f06409cf0f78916db4f4565d Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 20 Aug 2019 09:29:03 -0700 Subject: [PATCH] Bandwidth addition to interconnect (#4212) Signed-off-by: Modular Magician --- ...esource_compute_interconnect_attachment.go | 24 +++++++++++++++++++ ...pute_interconnect_attachment.html.markdown | 8 +++++++ 2 files changed, 32 insertions(+) diff --git a/google/resource_compute_interconnect_attachment.go b/google/resource_compute_interconnect_attachment.go index 4d1305a0662..d62baa8d557 100644 --- a/google/resource_compute_interconnect_attachment.go +++ b/google/resource_compute_interconnect_attachment.go @@ -54,6 +54,13 @@ func resourceComputeInterconnectAttachment() *schema.Resource { ForceNew: true, DiffSuppressFunc: compareSelfLinkOrResourceName, }, + "bandwidth": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"BPS_50M", "BPS_100M", "BPS_200M", "BPS_300M", "BPS_400M", "BPS_500M", "BPS_1G", "BPS_2G", "BPS_5G", "BPS_10G", "BPS_20G", "BPS_50G", ""}, false), + }, "candidate_subnets": { Type: schema.TypeList, Optional: true, @@ -169,6 +176,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 } + bandwidthProp, err := expandComputeInterconnectAttachmentBandwidth(d.Get("bandwidth"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("bandwidth"); !isEmptyValue(reflect.ValueOf(bandwidthProp)) && (ok || !reflect.DeepEqual(v, bandwidthProp)) { + obj["bandwidth"] = bandwidthProp + } edgeAvailabilityDomainProp, err := expandComputeInterconnectAttachmentEdgeAvailabilityDomain(d.Get("edge_availability_domain"), d, config) if err != nil { return err @@ -288,6 +301,9 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte if err := d.Set("description", flattenComputeInterconnectAttachmentDescription(res["description"], d)); err != nil { return fmt.Errorf("Error reading InterconnectAttachment: %s", err) } + if err := d.Set("bandwidth", flattenComputeInterconnectAttachmentBandwidth(res["bandwidth"], d)); err != nil { + return fmt.Errorf("Error reading InterconnectAttachment: %s", err) + } if err := d.Set("edge_availability_domain", flattenComputeInterconnectAttachmentEdgeAvailabilityDomain(res["edgeAvailabilityDomain"], d)); err != nil { return fmt.Errorf("Error reading InterconnectAttachment: %s", err) } @@ -410,6 +426,10 @@ func flattenComputeInterconnectAttachmentDescription(v interface{}, d *schema.Re return v } +func flattenComputeInterconnectAttachmentBandwidth(v interface{}, d *schema.ResourceData) interface{} { + return v +} + func flattenComputeInterconnectAttachmentEdgeAvailabilityDomain(v interface{}, d *schema.ResourceData) interface{} { return v } @@ -501,6 +521,10 @@ func expandComputeInterconnectAttachmentDescription(v interface{}, d TerraformRe return v, nil } +func expandComputeInterconnectAttachmentBandwidth(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandComputeInterconnectAttachmentEdgeAvailabilityDomain(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } diff --git a/website/docs/r/compute_interconnect_attachment.html.markdown b/website/docs/r/compute_interconnect_attachment.html.markdown index 11f4a2cfb6b..4bdad9a4dff 100644 --- a/website/docs/r/compute_interconnect_attachment.html.markdown +++ b/website/docs/r/compute_interconnect_attachment.html.markdown @@ -77,6 +77,14 @@ The following arguments are supported: (Optional) An optional description of this resource. +* `bandwidth` - + (Optional) + Provisioned bandwidth capacity for the interconnect attachment. + For attachments of type DEDICATED, the user can set the bandwidth. + For attachments of type PARTNER, the Google Partner that is operating the interconnect must set the bandwidth. + Output only for PARTNER type, mutable for PARTNER_PROVIDER and DEDICATED, + Defaults to BPS_10G + * `edge_availability_domain` - (Optional) Desired availability domain for the attachment. Only available for type