From e324cb923905a5e6265d88afdd0ad96a0f1b2031 Mon Sep 17 00:00:00 2001 From: Chris Stephens Date: Fri, 27 Dec 2019 19:07:46 +0000 Subject: [PATCH] Poll domain mapping until it succeeds Signed-off-by: Modular Magician --- google/resource_cloud_run_domain_mapping.go | 15 ++++++++++++++- .../docs/r/cloud_run_domain_mapping.html.markdown | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/google/resource_cloud_run_domain_mapping.go b/google/resource_cloud_run_domain_mapping.go index 1c0f68046b3..129731e94e0 100644 --- a/google/resource_cloud_run_domain_mapping.go +++ b/google/resource_cloud_run_domain_mapping.go @@ -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), }, @@ -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) diff --git a/website/docs/r/cloud_run_domain_mapping.html.markdown b/website/docs/r/cloud_run_domain_mapping.html.markdown index 17f4dd68d71..3016e1d0e08 100644 --- a/website/docs/r/cloud_run_domain_mapping.html.markdown +++ b/website/docs/r/cloud_run_domain_mapping.html.markdown @@ -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