Skip to content

Commit 37fe172

Browse files
authored
Merge pull request #1697 from onjen/fix-1142
fix(gcpkms): Set quota project to API project
2 parents bf5e7ae + 9870b99 commit 37fe172

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gcpkms/keysource.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,14 @@ func (key *MasterKey) TypeToIdentifier() string {
280280
// It returns an error if the ResourceID is invalid, or if the setup of the
281281
// client fails.
282282
func (key *MasterKey) newKMSClient(ctx context.Context) (*kms.KeyManagementClient, error) {
283-
re := regexp.MustCompile(`^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$`)
283+
re := regexp.MustCompile(`^projects/(?P<project>[^/]+)/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$`)
284284
matches := re.FindStringSubmatch(key.ResourceID)
285285
if matches == nil {
286286
return nil, fmt.Errorf("no valid resource ID found in %q", key.ResourceID)
287287
}
288288

289289
var opts []option.ClientOption
290+
opts = append(opts, option.WithQuotaProject(matches[1]))
290291
switch {
291292
case key.tokenSource != nil:
292293
opts = append(opts, option.WithTokenSource(key.tokenSource))

0 commit comments

Comments
 (0)