Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable timeouts to subnetworks #871

Merged
merged 1 commit into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions google/resource_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
computeBeta "google.golang.org/api/compute/v0.beta"
"google.golang.org/api/compute/v1"
"time"
)

var (
Expand All @@ -28,6 +29,12 @@ func resourceComputeSubnetwork() *schema.Resource {
State: resourceComputeSubnetworkImportState,
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(6 * time.Minute),
Update: schema.DefaultTimeout(6 * time.Minute),
Delete: schema.DefaultTimeout(6 * time.Minute),
},

Schema: map[string]*schema.Schema{
"ip_cidr_range": &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -152,7 +159,7 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e
subnetwork.Region = region
d.SetId(createSubnetID(subnetwork))

err = computeSharedOperationWait(config.clientCompute, op, project, "Creating Subnetwork")
err = computeSharedOperationWaitTime(config.clientCompute, op, project, int(d.Timeout(schema.TimeoutCreate).Minutes()), "Creating Subnetwork")
if err != nil {
return err
}
Expand Down Expand Up @@ -264,7 +271,7 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error updating subnetwork PrivateIpGoogleAccess: %s", err)
}

err = computeSharedOperationWait(config.clientCompute, op, project, "Updating Subnetwork PrivateIpGoogleAccess")
err = computeSharedOperationWaitTime(config.clientCompute, op, project, int(d.Timeout(schema.TimeoutUpdate).Minutes()), "Updating Subnetwork PrivateIpGoogleAccess")
if err != nil {
return err
}
Expand All @@ -284,7 +291,7 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error updating subnetwork SecondaryIpRanges: %s", err)
}

err = computeSharedOperationWait(config.clientCompute, op, project, "Updating Subnetwork SecondaryIpRanges")
err = computeSharedOperationWaitTime(config.clientCompute, op, project, int(d.Timeout(schema.TimeoutUpdate).Minutes()), "Updating Subnetwork SecondaryIpRanges")
if err != nil {
return err
}
Expand Down Expand Up @@ -317,7 +324,7 @@ func resourceComputeSubnetworkDelete(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error deleting subnetwork: %s", err)
}

err = computeSharedOperationWait(config.clientCompute, op, project, "Deleting Subnetwork")
err = computeSharedOperationWaitTime(config.clientCompute, op, project, int(d.Timeout(schema.TimeoutDelete).Minutes()), "Deleting Subnetwork")
if err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/compute_subnetwork.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ exported:

* `self_link` - The URI of the created resource.

## Timeouts

This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - Default is `6 minutes`
- `update` - Default is `6 minutes`
- `delete` - Default is `6 minutes`

## Import

Subnetwork can be imported using the `region` and `name`, e.g.
Expand Down