Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): local KMS override local endpoint via env variable #240

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@
"command": "npx graphql-codegen --watch"
},
"docker:build": {
"dependsOn": ["build"],
"executor": "@nx-tools/nx-container:build",
"inputs": ["{projectRoot}/../../dist/apps/server"],
"defaultConfiguration": "local",
"options": {},
"configurations": {
"local": {
"tags": ["pezzolabs/pezzo-private/notifications-service"],
"tags": ["pezzolabs/pezzo/server"],
"push": false
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/app/config/common-config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const commonConfigSchema = {
REDIS_TLS_ENABLED: Joi.boolean().default(false),
KMS_REGION: Joi.string().default("us-east-1"),
KMS_LOCAL: Joi.boolean().default(true),
KMS_LOCAL_ENDPOINT: Joi.string().default("http://localhost:9981"),
KMS_KEY_ARN: Joi.string().default(
"arn:aws:kms:us-east-1:111122223333:key/demo-master-key"
),
Expand Down
14 changes: 10 additions & 4 deletions apps/server/src/app/encryption/encryption.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ export class EncryptionService {
const isLocalKMS = this.config.get("KMS_LOCAL");
const region = this.config.get("KMS_REGION");

const endpoint = isLocalKMS
? this.config.get("KMS_LOCAL_ENDPOINT")
: undefined;

const credentials = isLocalKMS
? { accessKeyId: "", secretAccessKey: "" }
: undefined;

this.kms = new KMS({
region,
endpoint: isLocalKMS ? "http://localhost:9981" : undefined,
credentials: isLocalKMS
? { accessKeyId: "", secretAccessKey: "" }
: undefined,
endpoint,
credentials,
});
}

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ services:
command: '-c "echo \"S2V5czoKICBTeW1tZXRyaWM6CiAgICBBZXM6CiAgICAgIC0gTWV0YWRhdGE6CiAgICAgICAgICBLZXlJZDogZGVtby1tYXN0ZXIta2V5CiAgICAgICAgQmFja2luZ0tleXM6CiAgICAgICAgICAtIDVjZGFlYWQyN2ZlN2RhMmRlNDc5NDVkNzNjZDZkNzllMzY0OTRlNzM4MDJmM2NkMzg2OWYxZDJjYjBiNWQ3YTkKCkFsaWFzZXM6CiAgLSBBbGlhc05hbWU6IGFsaWFzL3Rlc3RpbmcKICAgIFRhcmdldEtleUlkOiBkZW1vLW1hc3Rlci1rZXk=\" | base64 -d >> /init/seed.yaml && local-kms"'
ports:
- "9981:9981"
expose:
- "9981"
environment:
- "PORT=9981"
- "KMS_REGION=us-east-1"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
- SUPERTOKENS_CONNECTION_URI=http://supertokens:3567
- OPENSEARCH_URL=http://opensearch-node1:9200
- REDIS_URL=redis://redis-stack-server:6379
- KMS_LOCAL_ENDPOINT=http://local-kms:9981
ports:
- "3000:3000"
depends_on:
Expand Down
Loading