Skip to content

Commit

Permalink
fix: vpcep approval can working cross-project (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lance52259 authored Mar 31, 2021
1 parent 0661ae5 commit 8d5dbb8
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion huaweicloud/resource_huaweicloud_vpcep_approval.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func doConnectionAction(d *schema.ResourceData, client *golangsdk.ServiceClient,
stateConf := &resource.StateChangeConf{
Pending: []string{"creating", "pendingAcceptance"},
Target: []string{targetStatus},
Refresh: waitForVPCEndpointStatus(client, epID),
Refresh: waitForVPCEndpointConnected(client, serviceID, epID),
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 3 * time.Second,
MinTimeout: 3 * time.Second,
Expand All @@ -210,3 +210,22 @@ func doConnectionAction(d *schema.ResourceData, client *golangsdk.ServiceClient,

return nil
}

func waitForVPCEndpointConnected(vpcepClient *golangsdk.ServiceClient, serviceId, endpointId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
listOpts := services.ListConnOpts{
EndpointID: endpointId,
}
connections, err := services.ListConnections(vpcepClient, serviceId, listOpts)
if err != nil {
if _, ok := err.(golangsdk.ErrDefault404); ok {
return connections, "deleted", nil
}
return connections, "error", err
}
if len(connections) == 1 && connections[0].EndpointID == endpointId {
return connections, connections[0].Status, nil
}
return connections, "deleted", nil
}
}

0 comments on commit 8d5dbb8

Please sign in to comment.