1import type * as SSM from "@distilled.cloud/aws/ssm";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Parameter } from "./Parameter.ts";
5
6export interface PutParameterRequest extends Omit<
7 SSM.PutParameterRequest,
8 "Name"
9> {}
10
11/**
12 * Runtime binding for `ssm:PutParameter`.
13 *
14 * Bind this operation to a `Parameter` inside a function runtime to get a
15 * callable that writes a new version of the bound parameter — e.g. flipping a
16 * feature flag or rotating a stored secret at runtime. For `SecureString`
17 * parameters the binding also grants `kms:Encrypt` and `kms:GenerateDataKey`
18 * on the parameter's encryption key.
19 *
20 * Pass `Overwrite: true` to update the existing parameter (the parameter
21 * already exists — it is managed by the `Parameter` resource). Note that a
22 * runtime write drifts the value from the deployed desired state; the next
23 * deploy converges it back.
24 * ### Writing a Parameter
25 * **Example:** Update a Feature Flag at Runtime
26 * ```typescript
27 * const putFlag = yield* SSM.PutParameter(flag);
28 *
29 * const result = yield* putFlag({ Value: "on", Overwrite: true });
30 * yield* Effect.log(`flag now at version ${result.Version}`);
31 * ```
32 *
33 * @binding
34 */
35export interface PutParameter extends Binding.Service<
36 PutParameter,
37 "AWS.SSM.PutParameter",
38 <P extends Parameter>(
39 parameter: P,
40 ) => Effect.Effect<
41 (
42 request: PutParameterRequest,
43 ) => Effect.Effect<SSM.PutParameterResult, SSM.PutParameterError>
44 >
45> {}
46export const PutParameter = Binding.Service<PutParameter>(
47 "AWS.SSM.PutParameter",
48);