diff --git a/providers/gcp/services/memorystore/client.go b/providers/gcp/services/memorystore/client.go index cddd7c8..020bea2 100644 --- a/providers/gcp/services/memorystore/client.go +++ b/providers/gcp/services/memorystore/client.go @@ -544,6 +544,9 @@ func (c *Client) convertGCPRecommendation(ctx context.Context, gcpRec *recommend return rec } +// memorystoreRedisServiceID is the Cloud Billing service for Cloud Memorystore for Redis. +const memorystoreRedisServiceID = "services/5AF5-2C11-D467" + // listSKUs returns the service's SKU catalog, listing it once per client so // that pricing N recommendations costs one catalog read instead of N. func (c *Client) listSKUs(svc BillingService) (*cloudbilling.ListSkusResponse, error) { @@ -552,7 +555,7 @@ func (c *Client) listSKUs(svc BillingService) (*cloudbilling.ListSkusResponse, e if c.skuCache != nil { return c.skuCache, nil } - skus, err := svc.ListSKUs("services/D559-82DA-3A56") + skus, err := svc.ListSKUs(memorystoreRedisServiceID) if err != nil { return nil, err } diff --git a/providers/gcp/services/memorystore/service_id_test.go b/providers/gcp/services/memorystore/service_id_test.go new file mode 100644 index 0000000..59befc2 --- /dev/null +++ b/providers/gcp/services/memorystore/service_id_test.go @@ -0,0 +1,29 @@ +package memorystore + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/api/cloudbilling/v1" +) + +type serviceIDSpy struct{ got []string } + +func (s *serviceIDSpy) ListSKUs(serviceID string) (*cloudbilling.ListSkusResponse, error) { + s.got = append(s.got, serviceID) + return &cloudbilling.ListSkusResponse{}, nil +} + +// Regression for #380: the previous ID returned 404 from the live Billing API. +func TestListSKUs_UsesMemorystoreForRedisServiceID(t *testing.T) { + client, err := NewClient(context.Background(), "test-project", "us-central1") + require.NoError(t, err) + spy := &serviceIDSpy{} + + _, err = client.listSKUs(spy) + + require.NoError(t, err) + assert.Equal(t, []string{"services/5AF5-2C11-D467"}, spy.got) +}