mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Add fields to InterconnectAttachment to allow for PARTNER interconnects (#2959)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
b58053fe5d
commit
fdeac73ab6
@ -22,6 +22,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform/helper/validation"
|
||||||
"google.golang.org/api/compute/v1"
|
"google.golang.org/api/compute/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,12 +42,6 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"interconnect": {
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
ForceNew: true,
|
|
||||||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
@ -72,6 +67,17 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
"edge_availability_domain": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
"interconnect": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||||
|
},
|
||||||
"region": {
|
"region": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@ -79,6 +85,13 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
DiffSuppressFunc: compareSelfLinkOrResourceName,
|
||||||
},
|
},
|
||||||
|
"type": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
ValidateFunc: validation.StringInSlice([]string{"DEDICATED", "PARTNER", "PARTNER_PROVIDER", ""}, false),
|
||||||
|
},
|
||||||
"vlan_tag8021q": {
|
"vlan_tag8021q": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@ -100,6 +113,14 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"pairing_key": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"partner_asn": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"private_interconnect_info": {
|
"private_interconnect_info": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@ -113,6 +134,10 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"state": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"project": {
|
"project": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@ -143,6 +168,18 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in
|
|||||||
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
|
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
|
||||||
obj["description"] = descriptionProp
|
obj["description"] = descriptionProp
|
||||||
}
|
}
|
||||||
|
edgeAvailabilityDomainProp, err := expandComputeInterconnectAttachmentEdgeAvailabilityDomain(d.Get("edge_availability_domain"), d, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if v, ok := d.GetOkExists("edge_availability_domain"); !isEmptyValue(reflect.ValueOf(edgeAvailabilityDomainProp)) && (ok || !reflect.DeepEqual(v, edgeAvailabilityDomainProp)) {
|
||||||
|
obj["edgeAvailabilityDomain"] = edgeAvailabilityDomainProp
|
||||||
|
}
|
||||||
|
typeProp, err := expandComputeInterconnectAttachmentType(d.Get("type"), d, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if v, ok := d.GetOkExists("type"); !isEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
|
||||||
|
obj["type"] = typeProp
|
||||||
|
}
|
||||||
routerProp, err := expandComputeInterconnectAttachmentRouter(d.Get("router"), d, config)
|
routerProp, err := expandComputeInterconnectAttachmentRouter(d.Get("router"), d, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -250,9 +287,24 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
|
|||||||
if err := d.Set("description", flattenComputeInterconnectAttachmentDescription(res["description"], d)); err != nil {
|
if err := d.Set("description", flattenComputeInterconnectAttachmentDescription(res["description"], d)); err != nil {
|
||||||
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
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)
|
||||||
|
}
|
||||||
|
if err := d.Set("pairing_key", flattenComputeInterconnectAttachmentPairingKey(res["pairingKey"], d)); err != nil {
|
||||||
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
|
}
|
||||||
|
if err := d.Set("partner_asn", flattenComputeInterconnectAttachmentPartnerAsn(res["partnerAsn"], d)); err != nil {
|
||||||
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
|
}
|
||||||
if err := d.Set("private_interconnect_info", flattenComputeInterconnectAttachmentPrivateInterconnectInfo(res["privateInterconnectInfo"], d)); err != nil {
|
if err := d.Set("private_interconnect_info", flattenComputeInterconnectAttachmentPrivateInterconnectInfo(res["privateInterconnectInfo"], d)); err != nil {
|
||||||
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
}
|
}
|
||||||
|
if err := d.Set("type", flattenComputeInterconnectAttachmentType(res["type"], d)); err != nil {
|
||||||
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
|
}
|
||||||
|
if err := d.Set("state", flattenComputeInterconnectAttachmentState(res["state"], d)); err != nil {
|
||||||
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
|
}
|
||||||
if err := d.Set("google_reference_id", flattenComputeInterconnectAttachmentGoogleReferenceId(res["googleReferenceId"], d)); err != nil {
|
if err := d.Set("google_reference_id", flattenComputeInterconnectAttachmentGoogleReferenceId(res["googleReferenceId"], d)); err != nil {
|
||||||
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
return fmt.Errorf("Error reading InterconnectAttachment: %s", err)
|
||||||
}
|
}
|
||||||
@ -350,6 +402,18 @@ func flattenComputeInterconnectAttachmentDescription(v interface{}, d *schema.Re
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentEdgeAvailabilityDomain(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentPairingKey(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentPartnerAsn(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func flattenComputeInterconnectAttachmentPrivateInterconnectInfo(v interface{}, d *schema.ResourceData) interface{} {
|
func flattenComputeInterconnectAttachmentPrivateInterconnectInfo(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil
|
return nil
|
||||||
@ -373,6 +437,14 @@ func flattenComputeInterconnectAttachmentPrivateInterconnectInfoTag8021q(v inter
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentType(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenComputeInterconnectAttachmentState(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func flattenComputeInterconnectAttachmentGoogleReferenceId(v interface{}, d *schema.ResourceData) interface{} {
|
func flattenComputeInterconnectAttachmentGoogleReferenceId(v interface{}, d *schema.ResourceData) interface{} {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@ -421,6 +493,14 @@ func expandComputeInterconnectAttachmentDescription(v interface{}, d *schema.Res
|
|||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func expandComputeInterconnectAttachmentEdgeAvailabilityDomain(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func expandComputeInterconnectAttachmentType(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
func expandComputeInterconnectAttachmentRouter(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
func expandComputeInterconnectAttachmentRouter(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
|
||||||
f, err := parseRegionalFieldValue("routers", v.(string), "project", "region", "zone", d, config, true)
|
f, err := parseRegionalFieldValue("routers", v.(string), "project", "region", "zone", d, config, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -47,11 +47,6 @@ resource "google_compute_router" "foobar" {
|
|||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
|
|
||||||
* `interconnect` -
|
|
||||||
(Required)
|
|
||||||
URL of the underlying Interconnect object that this attachment's traffic will
|
|
||||||
traverse through.
|
|
||||||
|
|
||||||
* `router` -
|
* `router` -
|
||||||
(Required)
|
(Required)
|
||||||
URL of the cloud router to be used for dynamic routing. This router must be in
|
URL of the cloud router to be used for dynamic routing. This router must be in
|
||||||
@ -72,10 +67,30 @@ The following arguments are supported:
|
|||||||
- - -
|
- - -
|
||||||
|
|
||||||
|
|
||||||
|
* `interconnect` -
|
||||||
|
(Optional)
|
||||||
|
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.
|
||||||
|
|
||||||
* `description` -
|
* `description` -
|
||||||
(Optional)
|
(Optional)
|
||||||
An optional description of this resource.
|
An optional description of this resource.
|
||||||
|
|
||||||
|
* `edge_availability_domain` -
|
||||||
|
(Optional)
|
||||||
|
Desired availability domain for the attachment. Only available for type
|
||||||
|
PARTNER, at creation time. For improved reliability, customers should
|
||||||
|
configure a pair of attachments with one per availability domain. The
|
||||||
|
selected availability domain will be provided to the Partner via the
|
||||||
|
pairing key so that the provisioned circuit will lie in the specified
|
||||||
|
domain. If not specified, the value will default to AVAILABILITY_DOMAIN_ANY.
|
||||||
|
|
||||||
|
* `type` -
|
||||||
|
(Optional)
|
||||||
|
The type of InterconnectAttachment you wish to create. Defaults to
|
||||||
|
DEDICATED.
|
||||||
|
|
||||||
* `candidate_subnets` -
|
* `candidate_subnets` -
|
||||||
(Optional)
|
(Optional)
|
||||||
Up to 16 candidate prefixes that can be used to restrict the allocation
|
Up to 16 candidate prefixes that can be used to restrict the allocation
|
||||||
@ -110,10 +125,23 @@ In addition to the arguments listed above, the following computed attributes are
|
|||||||
IPv4 address + prefix length to be configured on the customer
|
IPv4 address + prefix length to be configured on the customer
|
||||||
router subinterface for this interconnect attachment.
|
router subinterface for this interconnect attachment.
|
||||||
|
|
||||||
|
* `pairing_key` -
|
||||||
|
[Output only for type PARTNER. Not present for DEDICATED]. The opaque
|
||||||
|
identifier of an PARTNER attachment used to initiate provisioning with
|
||||||
|
a selected partner. Of the form "XXXXX/region/domain"
|
||||||
|
|
||||||
|
* `partner_asn` -
|
||||||
|
[Output only for type PARTNER. Not present for DEDICATED]. Optional
|
||||||
|
BGP ASN for the router that should be supplied by a layer 3 Partner if
|
||||||
|
they configured BGP on behalf of the customer.
|
||||||
|
|
||||||
* `private_interconnect_info` -
|
* `private_interconnect_info` -
|
||||||
Information specific to an InterconnectAttachment. This property
|
Information specific to an InterconnectAttachment. This property
|
||||||
is populated if the interconnect that this is attached to is of type DEDICATED. Structure is documented below.
|
is populated if the interconnect that this is attached to is of type DEDICATED. Structure is documented below.
|
||||||
|
|
||||||
|
* `state` -
|
||||||
|
[Output Only] The current state of this attachment's functionality.
|
||||||
|
|
||||||
* `google_reference_id` -
|
* `google_reference_id` -
|
||||||
Google reference ID, to be used when raising support tickets with
|
Google reference ID, to be used when raising support tickets with
|
||||||
Google or otherwise to debug backend connectivity issues.
|
Google or otherwise to debug backend connectivity issues.
|
||||||
|
Loading…
Reference in New Issue
Block a user