@@ -49,6 +49,7 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
4949 return & schema.Resource {
5050 Create : resourceComputeInterconnectAttachmentCreate ,
5151 Read : resourceComputeInterconnectAttachmentRead ,
52+ Update : resourceComputeInterconnectAttachmentUpdate ,
5253 Delete : resourceComputeInterconnectAttachmentDelete ,
5354
5455 Importer : & schema.ResourceImporter {
@@ -57,6 +58,7 @@ func resourceComputeInterconnectAttachment() *schema.Resource {
5758
5859 Timeouts : & schema.ResourceTimeout {
5960 Create : schema .DefaultTimeout (10 * time .Minute ),
61+ Update : schema .DefaultTimeout (4 * time .Minute ),
6062 Delete : schema .DefaultTimeout (10 * time .Minute ),
6163 },
6264
@@ -86,9 +88,9 @@ Cloud Router is configured.`,
8688 "admin_enabled" : {
8789 Type : schema .TypeBool ,
8890 Optional : true ,
89- ForceNew : true ,
9091 Description : `Whether the VLAN attachment is enabled or disabled. When using
9192PARTNER type this will Pre-Activate the interconnect attachment` ,
93+ Default : true ,
9294 },
9395 "bandwidth" : {
9496 Type : schema .TypeString ,
@@ -120,7 +122,6 @@ Google will randomly select an unused /29 from all of link-local space.`,
120122 "description" : {
121123 Type : schema .TypeString ,
122124 Optional : true ,
123- ForceNew : true ,
124125 Description : `An optional description of this resource.` ,
125126 },
126127 "edge_availability_domain" : {
@@ -147,7 +148,6 @@ be set if type is PARTNER.`,
147148 Type : schema .TypeString ,
148149 Computed : true ,
149150 Optional : true ,
150- ForceNew : true ,
151151 DiffSuppressFunc : compareSelfLinkOrResourceName ,
152152 Description : `Region where the regional interconnect attachment resides.` ,
153153 },
@@ -248,7 +248,7 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in
248248 adminEnabledProp , err := expandComputeInterconnectAttachmentAdminEnabled (d .Get ("admin_enabled" ), d , config )
249249 if err != nil {
250250 return err
251- } else if v , ok := d .GetOkExists ("admin_enabled" ); ! isEmptyValue ( reflect . ValueOf ( adminEnabledProp )) && ( ok || ! reflect .DeepEqual (v , adminEnabledProp ) ) {
251+ } else if v , ok := d .GetOkExists ("admin_enabled" ); ok || ! reflect .DeepEqual (v , adminEnabledProp ) {
252252 obj ["adminEnabled" ] = adminEnabledProp
253253 }
254254 interconnectProp , err := expandComputeInterconnectAttachmentInterconnect (d .Get ("interconnect" ), d , config )
@@ -422,9 +422,6 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
422422 if err := d .Set ("name" , flattenComputeInterconnectAttachmentName (res ["name" ], d , config )); err != nil {
423423 return fmt .Errorf ("Error reading InterconnectAttachment: %s" , err )
424424 }
425- if err := d .Set ("candidate_subnets" , flattenComputeInterconnectAttachmentCandidateSubnets (res ["candidateSubnets" ], d , config )); err != nil {
426- return fmt .Errorf ("Error reading InterconnectAttachment: %s" , err )
427- }
428425 if err := d .Set ("vlan_tag8021q" , flattenComputeInterconnectAttachmentVlanTag8021q (res ["vlanTag8021q" ], d , config )); err != nil {
429426 return fmt .Errorf ("Error reading InterconnectAttachment: %s" , err )
430427 }
@@ -438,6 +435,57 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte
438435 return nil
439436}
440437
438+ func resourceComputeInterconnectAttachmentUpdate (d * schema.ResourceData , meta interface {}) error {
439+ config := meta .(* Config )
440+
441+ project , err := getProject (d , config )
442+ if err != nil {
443+ return err
444+ }
445+
446+ obj := make (map [string ]interface {})
447+ adminEnabledProp , err := expandComputeInterconnectAttachmentAdminEnabled (d .Get ("admin_enabled" ), d , config )
448+ if err != nil {
449+ return err
450+ } else if v , ok := d .GetOkExists ("admin_enabled" ); ok || ! reflect .DeepEqual (v , adminEnabledProp ) {
451+ obj ["adminEnabled" ] = adminEnabledProp
452+ }
453+ descriptionProp , err := expandComputeInterconnectAttachmentDescription (d .Get ("description" ), d , config )
454+ if err != nil {
455+ return err
456+ } else if v , ok := d .GetOkExists ("description" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , descriptionProp )) {
457+ obj ["description" ] = descriptionProp
458+ }
459+ regionProp , err := expandComputeInterconnectAttachmentRegion (d .Get ("region" ), d , config )
460+ if err != nil {
461+ return err
462+ } else if v , ok := d .GetOkExists ("region" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , regionProp )) {
463+ obj ["region" ] = regionProp
464+ }
465+
466+ url , err := replaceVars (d , config , "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/interconnectAttachments/{{name}}" )
467+ if err != nil {
468+ return err
469+ }
470+
471+ log .Printf ("[DEBUG] Updating InterconnectAttachment %q: %#v" , d .Id (), obj )
472+ res , err := sendRequestWithTimeout (config , "PATCH" , project , url , obj , d .Timeout (schema .TimeoutUpdate ))
473+
474+ if err != nil {
475+ return fmt .Errorf ("Error updating InterconnectAttachment %q: %s" , d .Id (), err )
476+ }
477+
478+ err = computeOperationWaitTime (
479+ config , res , project , "Updating InterconnectAttachment" ,
480+ int (d .Timeout (schema .TimeoutUpdate ).Minutes ()))
481+
482+ if err != nil {
483+ return err
484+ }
485+
486+ return resourceComputeInterconnectAttachmentRead (d , meta )
487+ }
488+
441489func resourceComputeInterconnectAttachmentDelete (d * schema.ResourceData , meta interface {}) error {
442490 config := meta .(* Config )
443491
@@ -588,10 +636,6 @@ func flattenComputeInterconnectAttachmentName(v interface{}, d *schema.ResourceD
588636 return v
589637}
590638
591- func flattenComputeInterconnectAttachmentCandidateSubnets (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
592- return v
593- }
594-
595639func flattenComputeInterconnectAttachmentVlanTag8021q (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
596640 // Handles the string fixed64 format
597641 if strVal , ok := v .(string ); ok {
0 commit comments