@@ -30,6 +30,14 @@ const (
3030 // SopsGCPKMSClientTypeEnv is the environment variable used to specify the
3131 // GCP KMS client type. Valid values are "grpc" (default) and "rest".
3232 SopsGCPKMSClientTypeEnv = "SOPS_GCP_KMS_CLIENT_TYPE"
33+ // SopsGCPKMSEndpointEnv overrides the GCP KMS endpoint URL. Useful for
34+ // sovereign cloud environments that expose a GCP-compatible KMS API at a
35+ // non-standard endpoint (e.g. S3NS/Thales TPC: cloudkms.s3nsapis.fr).
36+ SopsGCPKMSEndpointEnv = "SOPS_GCP_KMS_ENDPOINT"
37+ // SopsGCPKMSUniverseDomainEnv sets the universe domain for the GCP KMS
38+ // client, which derives the endpoint as cloudkms.{UNIVERSE_DOMAIN}:443.
39+ // Example: "s3nsapis.fr" for S3NS/Thales TPC.
40+ SopsGCPKMSUniverseDomainEnv = "SOPS_GCP_KMS_UNIVERSE_DOMAIN"
3341 // KeyTypeIdentifier is the string used to identify a GCP KMS MasterKey.
3442 KeyTypeIdentifier = "gcp_kms"
3543)
@@ -320,6 +328,12 @@ func (key *MasterKey) newKMSClient(ctx context.Context) (*kms.KeyManagementClien
320328 // Add extra options.
321329 opts = append (opts , key .clientOpts ... )
322330
331+ if endpoint := os .Getenv (SopsGCPKMSEndpointEnv ); endpoint != "" {
332+ opts = append (opts , option .WithEndpoint (endpoint ))
333+ } else if ud := os .Getenv (SopsGCPKMSUniverseDomainEnv ); ud != "" {
334+ opts = append (opts , option .WithUniverseDomain (ud ))
335+ }
336+
323337 // Select client type based on inputs.
324338 clientType := strings .ToLower (os .Getenv (SopsGCPKMSClientTypeEnv ))
325339 var client * kms.KeyManagementClient
0 commit comments