Skip to content

Parameter

Source: src/AWS/SSM/Parameter.ts

An AWS Systems Manager (SSM) Parameter Store parameter.

Parameter owns the lifecycle of a String, StringList, or SecureString parameter. A parameter name is auto-generated from the app, stage, and logical ID unless you provide one explicitly. Standard-tier parameters are free, making them ideal for configuration values, feature flags, and small secrets.

String Parameter

import * as SSM from "alchemy/AWS/SSM";
const config = yield* SSM.Parameter("DatabaseUrl", {
value: "postgres://db.example.com:5432/app",
});

StringList Parameter

const subnets = yield* SSM.Parameter("AllowedOrigins", {
type: "StringList",
value: "https://a.example.com,https://b.example.com",
});

Parameter with a Hierarchical Name

const param = yield* SSM.Parameter("DbUrl", {
name: "/my-app/prod/db-url",
value: "postgres://db.example.com:5432/app",
});

Encrypted with the AWS-managed key

import * as Redacted from "effect/Redacted";
const apiKey = yield* SSM.Parameter("ApiKey", {
type: "SecureString",
value: Redacted.make("super-secret-value"),
});

Encrypted with a customer-managed KMS key

const key = yield* KMS.Key("SecretsKey");
const apiKey = yield* SSM.Parameter("ApiKey", {
type: "SecureString",
value: Redacted.make("super-secret-value"),
keyId: key.keyId,
});
const port = yield* SSM.Parameter("Port", {
value: "5432",
allowedPattern: "^\\d+$",
});

Bind read operations in the init phase and use them in runtime handlers.

// init
const getParameter = yield* SSM.GetParameter(config);
return {
fetch: Effect.gen(function* () {
// runtime
const result = yield* getParameter({ WithDecryption: true });
return HttpServerResponse.text(String(result.Parameter?.Value));
}),
};