Skip to content

Commit

Permalink
Poll domain mapping until it succeeds
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
chrisst committed Dec 27, 2019
1 parent 45b9027 commit e324cb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion google/resource_cloud_run_domain_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func resourceCloudRunDomainMapping() *schema.Resource {
},

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

Expand Down Expand Up @@ -292,6 +292,19 @@ func resourceCloudRunDomainMappingCreate(d *schema.ResourceData, meta interface{
}
d.SetId(id)

waitURL, err := replaceVars(d, config, "{{CloudRunBasePath}}apis/domains.cloudrun.com/v1/namespaces/{{project}}/domainmappings/{{name}}")
if err != nil {
return err
}

err = cloudRunPollingWaitTime(
config, res, project, waitURL, "Creating DomainMapping",
int(d.Timeout(schema.TimeoutCreate).Minutes()))

if err != nil {
return fmt.Errorf("Error waiting to create DomainMapping: %s", err)
}

log.Printf("[DEBUG] Finished creating DomainMapping %q: %#v", d.Id(), res)

return resourceCloudRunDomainMappingRead(d, meta)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cloud_run_domain_mapping.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ The `resource_records` block supports:
This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - Default is 4 minutes.
- `create` - Default is 6 minutes.
- `delete` - Default is 4 minutes.

## Import
Expand Down

0 comments on commit e324cb9

Please sign in to comment.