@@ -30,6 +30,7 @@ func ResourceBigtableTable() *schema.Resource {
30
30
// Set a longer timeout for table creation as adding column families can be slow.
31
31
Timeouts : & schema.ResourceTimeout {
32
32
Create : schema .DefaultTimeout (45 * time .Minute ),
33
+ Update : schema .DefaultTimeout (20 * time .Minute ),
33
34
},
34
35
35
36
// ----------------------------------------------------------------------
@@ -157,7 +158,7 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error
157
158
// This method may return before the table's creation is complete - we may need to wait until
158
159
// it exists in the future.
159
160
// Set a longer timeout as creating table and adding column families can be pretty slow.
160
- ctxWithTimeout , cancel := context .WithTimeout (ctx , 20 * time . Minute )
161
+ ctxWithTimeout , cancel := context .WithTimeout (ctx , d . Timeout ( schema . TimeoutCreate ) )
161
162
defer cancel () // Always call cancel.
162
163
err = c .CreateTableFromConf (ctxWithTimeout , & tblConf )
163
164
if err != nil {
@@ -276,14 +277,16 @@ func resourceBigtableTableUpdate(d *schema.ResourceData, meta interface{}) error
276
277
}
277
278
}
278
279
280
+ ctxWithTimeout , cancel := context .WithTimeout (ctx , d .Timeout (schema .TimeoutCreate ))
281
+ defer cancel ()
279
282
if d .HasChange ("deletion_protection" ) {
280
283
deletionProtection := d .Get ("deletion_protection" )
281
284
if deletionProtection == "PROTECTED" {
282
- if err := c .UpdateTableWithDeletionProtection (ctx , name , bigtable .Protected ); err != nil {
285
+ if err := c .UpdateTableWithDeletionProtection (ctxWithTimeout , name , bigtable .Protected ); err != nil {
283
286
return fmt .Errorf ("Error updating deletion protection in table %v: %s" , name , err )
284
287
}
285
288
} else if deletionProtection == "UNPROTECTED" {
286
- if err := c .UpdateTableWithDeletionProtection (ctx , name , bigtable .Unprotected ); err != nil {
289
+ if err := c .UpdateTableWithDeletionProtection (ctxWithTimeout , name , bigtable .Unprotected ); err != nil {
287
290
return fmt .Errorf ("Error updating deletion protection in table %v: %s" , name , err )
288
291
}
289
292
}
0 commit comments