Skip to content

Commit

Permalink
fix vpc creation error (#246)
Browse files Browse the repository at this point in the history
ignoring the error when vpc endpoint doesn't exist

Signed-off-by: Sebastian Webber <sebastian@timescale.com>
  • Loading branch information
sebastianwebber authored Dec 3, 2024
1 parent 110ec4e commit f3bbd20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"math/big"
"strings"

"github.com/hashicorp/terraform-plugin-log/tflog"
)
Expand Down Expand Up @@ -169,7 +170,7 @@ func (c *Client) CreateService(ctx context.Context, request CreateServiceRequest
if err := c.do(ctx, req, &resp); err != nil {
return nil, err
}
if len(resp.Errors) > 0 {
if len(resp.Errors) > 0 && !strings.Contains(resp.Errors[0].Message, "no Endpoint for that service id exists") {
return nil, resp.Errors[0]
}
if resp.Data == nil {
Expand Down
7 changes: 4 additions & 3 deletions internal/provider/service_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
EnableConnectionPooler: plan.ConnectionPoolerEnabled.ValueBool(),
EnvironmentTag: plan.EnvironmentTag.ValueString(),
}
if !plan.VpcID.IsNull() {
request.VpcID = plan.VpcID.ValueInt64()
}

readReplicaSource := plan.ReadReplicaSource.ValueString()
if readReplicaSource != "" {
Expand Down Expand Up @@ -336,6 +333,10 @@ func (r *ServiceResource) Create(ctx context.Context, req resource.CreateRequest
}
}

if !plan.VpcID.IsNull() {
request.VpcID = plan.VpcID.ValueInt64()
}

response, err := r.client.CreateService(ctx, request)

if err != nil {
Expand Down

0 comments on commit f3bbd20

Please sign in to comment.