Skip to content

Commit

Permalink
add stack_type attribute (#9890) (#17139)
Browse files Browse the repository at this point in the history
[upstream:c9187077e083299f3c1d2fd4ce5cbbb397b1ae22]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 30, 2024
1 parent 815c34e commit 2f2d9a0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/9890.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `stack_type` attribute for `google_compute_interconnect_attachment` resource.
```
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ this interconnect attachment. Currently, only 1440 and 1500 are allowed. If not
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `Region where the regional interconnect attachment resides.`,
},
"stack_type": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ValidateFunc: verify.ValidateEnum([]string{"IPV4_IPV6", "IPV4_ONLY", ""}),
Description: `The stack type for this interconnect attachment to identify whether the IPv6
feature is enabled or not. If not specified, IPV4_ONLY will be used.
This field can be both set at interconnect attachments creation and update
interconnect attachment operations. Possible values: ["IPV4_IPV6", "IPV4_ONLY"]`,
},
"type": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -391,6 +402,12 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in
} else if v, ok := d.GetOkExists("encryption"); !tpgresource.IsEmptyValue(reflect.ValueOf(encryptionProp)) && (ok || !reflect.DeepEqual(v, encryptionProp)) {
obj["encryption"] = encryptionProp
}
stackTypeProp, err := expandComputeInterconnectAttachmentStackType(d.Get("stack_type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("stack_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(stackTypeProp)) && (ok || !reflect.DeepEqual(v, stackTypeProp)) {
obj["stackType"] = stackTypeProp
}
regionProp, err := expandComputeInterconnectAttachmentRegion(d.Get("region"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -556,6 +573,9 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
if err := d.Set("encryption", flattenComputeInterconnectAttachmentEncryption(res["encryption"], d, config)); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
if err := d.Set("stack_type", flattenComputeInterconnectAttachmentStackType(res["stackType"], d, config)); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
if err := d.Set("region", flattenComputeInterconnectAttachmentRegion(res["region"], d, config)); err != nil {
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
}
Expand Down Expand Up @@ -606,6 +626,12 @@ func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta in
} else if v, ok := d.GetOkExists("bandwidth"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, bandwidthProp)) {
obj["bandwidth"] = bandwidthProp
}
stackTypeProp, err := expandComputeInterconnectAttachmentStackType(d.Get("stack_type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("stack_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, stackTypeProp)) {
obj["stackType"] = stackTypeProp
}
regionProp, err := expandComputeInterconnectAttachmentRegion(d.Get("region"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -862,6 +888,10 @@ func flattenComputeInterconnectAttachmentEncryption(v interface{}, d *schema.Res
return v
}

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

func flattenComputeInterconnectAttachmentRegion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -937,6 +967,10 @@ func expandComputeInterconnectAttachmentEncryption(v interface{}, d tpgresource.
return v, nil
}

func expandComputeInterconnectAttachmentStackType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandComputeInterconnectAttachmentRegion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
f, err := tpgresource.ParseGlobalFieldValue("regions", v.(string), "project", d, config, true)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/compute_interconnect_attachment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ The following arguments are supported:
Default value is `NONE`.
Possible values are: `NONE`, `IPSEC`.

* `stack_type` -
(Optional)
The stack type for this interconnect attachment to identify whether the IPv6
feature is enabled or not. If not specified, IPV4_ONLY will be used.
This field can be both set at interconnect attachments creation and update
interconnect attachment operations.
Possible values are: `IPV4_IPV6`, `IPV4_ONLY`.

* `region` -
(Optional)
Region where the regional interconnect attachment resides.
Expand Down

0 comments on commit 2f2d9a0

Please sign in to comment.