An unofficial gRPC emulator for Google Cloud KMS aimed at local development and CI. It is not an official Google product—never load production secrets.
- Go 1.25+ required.
- Run:
go run ./cmd/fake-cloud-kms \
--grpc-listen-addr 127.0.0.1:9010 \
--store memory \
--log-level info \
--seed-file testdata/seeds.yaml # optional, YAML only- Point clients at the gRPC address (TLS is disabled). With the Go client library, pass
option.WithEndpoint(addr)andoption.WithoutAuthentication().
- Prebuilt image on Docker Hub: winor30/fake-cloud-kms.
- Run the emulator in a container (defaults to
--grpc-listen-addr 0.0.0.0:9010from the entrypoint):
docker run --rm -p 9010:9010 winor30/fake-cloud-kms:latest- To load seeds, mount them into the container and pass the file path:
docker run --rm -p 9010:9010 \
-v "$(pwd)/testdata/seeds.yaml:/data/seeds.yaml:ro" \
winor30/fake-cloud-kms:latest \
--seed-file /data/seeds.yaml- Resource RPCs: Create/Get/List KeyRing, CryptoKey, CryptoKeyVersion; UpdateCryptoKeyPrimaryVersion.
CreateCryptoKeyauto-creates version1(ENABLED); useCreateCryptoKeyVersionfor more. Pagination returnsUnimplemented. - Crypto: Encrypt/Decrypt using
GOOGLE_SYMMETRIC_ENCRYPTION(ProtectionLevel_SOFTWARE) with CRC32C verification for plaintext/ciphertext/AAD andUsedPrimaryreporting. - Storage/config: in-memory store only (state is ephemeral). Flags:
--grpc-listen-addr(default127.0.0.1:9010),--store(memoryonly),--seed-file(YAML),--log-level(debug|info|warn|error, defaultinfo).
- Destroy/Restore and state transitions beyond
ENABLEDare not implemented. - Other key purposes/algorithms/protection levels (MAC, asymmetric, raw encrypt, HSM/FIPS) are unsupported.
- No pagination and no TLS termination.
ctx := context.Background()
server, err := emulator.Start(ctx, emulator.Options{})
if err != nil {
log.Fatal(err)
}
defer server.Stop(ctx)
fmt.Println("addr:", server.Addr)projects:
demo:
locations:
global:
keyRings:
app-ring:
cryptoKeys:
app-key:
purpose: ENCRYPT_DECRYPT
labels:
env: dev
versions:
- {} # creates version 1
- {} # creates version 2clients/typescript: spins up the emulator via Testcontainers and exercises Encrypt/Decrypt through the official@google-cloud/kmsclient. Run withpnpm startor build the provided Docker image.
go build ./cmd/fake-cloud-kmsgo test ./...golangci-lint run ./...make fmt vet lint test buildto mirror CI.