All files / src/cli/infrastructure AwsSsmSecretProvider.ts

100% Statements 14/14
100% Branches 2/2
100% Functions 2/2
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 201x     1x     1x 8x 8x   1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { GetParameterCommand, type SSM } from '@aws-sdk/client-ssm';
import type { ISecretProvider } from '../domain/ports/ISecretProvider';
 
export class AwsSsmSecretProvider implements ISecretProvider {
  private ssm: SSM;
 
  constructor(ssm: SSM) {
    this.ssm = ssm;
  }
 
  async getSecret(name: string): Promise<string | undefined> {
    const command = new GetParameterCommand({
      Name: name,
      WithDecryption: true,
    });
    const { Parameter } = await this.ssm.send(command);
    return Parameter?.Value;
  }
}