mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-06 10:41:07 +00:00
Add vlan tag and subnet candidates to Interconnect Attachments. (#2882)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
d30a7c4af0
commit
f2649bcbdb
@ -59,6 +59,14 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||||
},
|
},
|
||||||
|
"candidate_subnets": {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
"description": {
|
"description": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@ -71,6 +79,11 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||||
},
|
},
|
||||||
|
"vlan_tag8021q": {
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
"cloud_router_ip_address": {
|
"cloud_router_ip_address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@ -142,6 +155,18 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in
|
|||||||
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) {
|
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) {
|
||||||
obj["name"] = nameProp
|
obj["name"] = nameProp
|
||||||
}
|
}
|
||||||
|
candidateSubnetsProp, err := expandComputeInterconnectAttachmentCandidateSubnets(d.Get("candidate_subnets"), d, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if v, ok := d.GetOkExists("candidate_subnets"); !isEmptyValue(reflect.ValueOf(candidateSubnetsProp)) && (ok || !reflect.DeepEqual(v, candidateSubnetsProp)) {
|
||||||
|
obj["candidateSubnets"] = candidateSubnetsProp
|
||||||
|
}
|
||||||
|
vlanTag8021qProp, err := expandComputeInterconnectAttachmentVlanTag8021q(d.Get("vlan_tag8021q"), d, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if v, ok := d.GetOkExists("vlan_tag8021q"); !isEmptyValue(reflect.ValueOf(vlanTag8021qProp)) && (ok || !reflect.DeepEqual(v, vlanTag8021qProp)) {
|
||||||
|
obj["vlanTag8021q"] = vlanTag8021qProp
|
||||||
|
}
|
||||||
regionProp, err := expandComputeInterconnectAttachmentRegion(d.Get("region"), d, config)
|
regionProp, err := expandComputeInterconnectAttachmentRegion(d.Get("region"), d, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -240,6 +265,12 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
|
|||||||
if err := d.Set("name", flattenComputeInterconnectAttachmentName(res["name"], d)); err != nil {
|
if err := d.Set("name", flattenComputeInterconnectAttachmentName(res["name"], d)); err != nil {
|
||||||
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
}
|
}
|
||||||
|
if err := d.Set("candidate_subnets", flattenComputeInterconnectAttachmentCandidateSubnets(res["candidateSubnets"], d)); err != nil {
|
||||||
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
|
}
|
||||||
|
if err := d.Set("vlan_tag8021q", flattenComputeInterconnectAttachmentVlanTag8021q(res["vlanTag8021q"], d)); err != nil {
|
||||||
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
|
}
|
||||||
if err := d.Set("region", flattenComputeInterconnectAttachmentRegion(res["region"], d)); err != nil {
|
if err := d.Set("region", flattenComputeInterconnectAttachmentRegion(res["region"], d)); err != nil {
|
||||||
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
}
|
}
|
||||||
@ -361,6 +392,20 @@ func flattenComputeInterconnectAttachmentName(v interface{}, d *schema.ResourceD
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentCandidateSubnets(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentVlanTag8021q(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
// Handles the string fixed64 format
|
||||||
|
if strVal, ok := v.(string); ok {
|
||||||
|
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
|
||||||
|
return intVal
|
||||||
|
} // let terraform core handle it if we can't convert the string to an int.
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func flattenComputeInterconnectAttachmentRegion(v interface{}, d *schema.ResourceData) interface{} {
|
func flattenComputeInterconnectAttachmentRegion(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return v
|
return v
|
||||||
@ -388,6 +433,14 @@ func expandComputeInterconnectAttachmentName(v interface{}, d *schema.ResourceDa
|
|||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func expandComputeInterconnectAttachmentCandidateSubnets(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func expandComputeInterconnectAttachmentVlanTag8021q(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
func expandComputeInterconnectAttachmentRegion(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
func expandComputeInterconnectAttachmentRegion(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||||
f, err := parseGlobalFieldValue("regions", v.(string), "project", d, config, true)
|
f, err := parseGlobalFieldValue("regions", v.(string), "project", d, config, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -76,6 +76,20 @@ The following arguments are supported:
|
|||||||
(Optional)
|
(Optional)
|
||||||
An optional description of this resource.
|
An optional description of this resource.
|
||||||
|
|
||||||
|
* `candidate_subnets` -
|
||||||
|
(Optional)
|
||||||
|
Up to 16 candidate prefixes that can be used to restrict the allocation
|
||||||
|
of cloudRouterIpAddress and customerRouterIpAddress for this attachment.
|
||||||
|
All prefixes must be within link-local address space (169.254.0.0/16)
|
||||||
|
and must be /29 or shorter (/28, /27, etc). Google will attempt to select
|
||||||
|
an unused /29 from the supplied candidate prefix(es). The request will
|
||||||
|
fail if all possible /29s are in use on Google's edge. If not supplied,
|
||||||
|
Google will randomly select an unused /29 from all of link-local space.
|
||||||
|
|
||||||
|
* `vlan_tag8021q` -
|
||||||
|
(Optional)
|
||||||
|
The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094.
|
||||||
|
|
||||||
* `region` -
|
* `region` -
|
||||||
(Optional)
|
(Optional)
|
||||||
Region where the regional interconnect attachment resides.
|
Region where the regional interconnect attachment resides.
|
||||||
|
Loading…
Reference in New Issue
Block a user