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 poll for 404 reads after creating an App Engine firewall rule #6633

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3663.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
appengine: Added polling to `google_app_engine_firewall_rule` to prevent issues with eventually consistent creation
```
26 changes: 26 additions & 0 deletions google/resource_app_engine_firewall_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,37 @@ func resourceAppEngineFirewallRuleCreate(d *schema.ResourceData, meta interface{
}
d.SetId(id)

err = PollingWaitTime(resourceAppEngineFirewallRulePollRead(d, meta), PollCheckForExistence, "Creating FirewallRule", d.Timeout(schema.TimeoutCreate))
if err != nil {
return fmt.Errorf("Error waiting to create FirewallRule: %s", err)
}

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

return resourceAppEngineFirewallRuleRead(d, meta)
}

func resourceAppEngineFirewallRulePollRead(d *schema.ResourceData, meta interface{}) PollReadFunc {
return func() (map[string]interface{}, error) {
config := meta.(*Config)

url, err := replaceVars(d, config, "{{AppEngineBasePath}}apps/{{project}}/firewall/ingressRules/{{priority}}")
if err != nil {
return nil, err
}

project, err := getProject(d, config)
if err != nil {
return nil, err
}
res, err := sendRequest(config, "GET", project, url, nil)
if err != nil {
return res, err
}
return res, nil
}
}

func resourceAppEngineFirewallRuleRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

Expand Down