Skip to content

Commit b2f6618

Browse files
authored
Added create and delete timeouts for cloudfoundry_service_key resource (#556)
* Change service_key resource create default timeout Change service_key resource create default timeout from 1 minute to 5 minutes. Generally, service key creation should not take more than a minute, but, if the service needs to execute complex operations as part of the key creation, this can take longer. * Revert "Change service_key resource create default timeout" This reverts commit 45a329b. * Added create and delete timeouts for cloudfoundry_service_key resource The defaults are not changed from the initial implementation (60 seconds for both). Generally, service key creation should not take more than a minute, but, if the service needs to execute complex operations, as, part of the key creation, this can take longer. * updated UT
1 parent 4a0bf96 commit b2f6618

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

cloudfoundry/resource_cf_service_key.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ func resourceServiceKey() *schema.Resource {
3131
StateContext: ImportReadContext(resourceServiceKeyRead),
3232
},
3333

34+
Timeouts: &schema.ResourceTimeout{
35+
Create: schema.DefaultTimeout(60 * time.Second),
36+
Delete: schema.DefaultTimeout(60 * time.Second),
37+
},
38+
3439
Schema: map[string]*schema.Schema{
3540

3641
"name": &schema.Schema{
@@ -146,7 +151,7 @@ func resourceServiceKeyCreate(ctx context.Context, d *schema.ResourceData, meta
146151

147152
// Last operation initial or inprogress or job not completed, continue polling
148153
return false, nil
149-
}, 5*time.Second, 60*time.Second)
154+
}, 5*time.Second, d.Timeout(schema.TimeoutCreate))
150155
if err != nil {
151156
return diag.FromErr(err)
152157
}
@@ -240,6 +245,6 @@ func resourceServiceKeyDelete(ctx context.Context, d *schema.ResourceData, meta
240245
}
241246
// Last operation initial or inprogress or job not completed, continue polling
242247
return false, nil
243-
}, 5*time.Second, 60*time.Second)
248+
}, 5*time.Second, d.Timeout(schema.TimeoutDelete))
244249
return diag.FromErr(err)
245250
}

cloudfoundry/resource_cf_service_key_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ resource "cloudfoundry_service_key" "test-service-instance-key" {
2828
"key1" = "aaaa"
2929
"key2" = "bbbb"
3030
}
31+
32+
timeouts {
33+
create = "3m"
34+
delete = "2m"
35+
}
3136
}
3237
`
3338

docs/resources/service_key.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,11 @@ An existing Service Key can be imported using its guid , e.g.
5454
```bash
5555
terraform import cloudfoundry_service_key.redis1-key1 a-guid
5656
```
57+
58+
### Timeouts
59+
60+
`cloudfoundry_service_key` provides the following
61+
[Timeouts](https://www.terraform.io/docs/configuration/blocks/resources/syntax.html#operation-timeouts) configuration options:
62+
63+
* `create` - (Default `60 seconds`) Used for Creating Instance.
64+
* `delete` - (Default `60 seconds`) Used for Destroying Instance.

0 commit comments

Comments
 (0)