@effect-aws/secrets-manager
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@effect-aws/secrets-manager

npm version npm downloads

This package provides a fromSecretsManager ConfigProvider constructor function. You can use it to read secrets from AWS Secrets Manager as a Config schema.

The config primitive name must match the secret Name or ARN in Secrets Manager. For example, Config.string("my_secret_name") or Config.string("arn:aws:secretsmanager:eu-central-1:123456789012:secret:my_secret_name-AbCdEf").

Installation

npm install --save @effect-aws/secrets-manager @effect-aws/client-secrets-manager

Usage

With default service layer:

import { Effect, Config, Console } from "effect";
import { fromSecretsManager } from "@effect-aws/secrets-manager";

const program = Effect.gen(function* () {
  const secret: string = yield* Config.string("my_secret_name");

  yield* Console.log("Secret from Secrets Manager: ", secret);
});

program.pipe(
  Effect.provide(Layer.setConfigProvider(fromSecretsManager())),
  Effect.runPromise,
);

With custom service layer:

import { Effect, Config, Console, Layer } from "effect";
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
import {
  BaseSecretsManagerServiceLayer,
  SecretsManagerClientInstance,
} from "@effect-aws/client-secrets-manager";
import { fromSecretsManager } from "@effect-aws/secrets-manager";

const program = Effect.gen(function* () {
  const secret: string = yield* Config.string("my_secret_name");

  yield* Console.log("Secret from Secrets Manager: ", secret);
});

const SecretsManagerClientInstanceLayer = Layer.succeed(
  SecretsManagerClientInstance,
  new SecretsManagerClient({ region: "eu-central-1" }),
);

const serviceLayer = Layer.provide(
  BaseSecretsManagerServiceLayer,
  SecretsManagerClientInstanceLayer,
);

program.pipe(
  Effect.provide(Layer.setConfigProvider(fromSecretsManager({ serviceLayer }))),
  Effect.runPromise,
);

Readme

Keywords

none

Package Sidebar

Install

npm i @effect-aws/secrets-manager

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

37.5 kB

Total Files

13

Last publish

Collaborators

  • f1oyd