| 1 | import type * as cloudcontrol from "@distilled.cloud/aws/cloudcontrol"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { CloudControlBindingOptions } from "./BindingOptions.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `cloudformation:GetResource`. |
| 8 | * |
| 9 | * Reads the current state of any Cloud Control-supported resource — whether |
| 10 | * or not it was provisioned through Cloud Control. Because Cloud Control |
| 11 | * invokes the resource type's read handler with the caller's credentials, |
| 12 | * pass the handler's underlying permissions via |
| 13 | * {@link CloudControlBindingOptions.handlerPolicyStatements}. |
| 14 | * ### Reading Resources |
| 15 | * **Example:** Read an SSM Parameter's live state |
| 16 | * ```typescript |
| 17 | * // init — account-level; grant the read handler's permissions too |
| 18 | * const getResource = yield* CloudControl.GetResource({ |
| 19 | * handlerPolicyStatements: [ |
| 20 | * { Effect: "Allow", Action: ["ssm:GetParameters"], Resource: ["*"] }, |
| 21 | * ], |
| 22 | * }); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const result = yield* getResource({ |
| 26 | * TypeName: "AWS::SSM::Parameter", |
| 27 | * Identifier: "/app/greeting", |
| 28 | * }); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface GetResource extends Binding.Service< |
| 34 | GetResource, |
| 35 | "AWS.CloudControl.GetResource", |
| 36 | ( |
| 37 | options?: CloudControlBindingOptions, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request: cloudcontrol.GetResourceInput, |
| 41 | ) => Effect.Effect< |
| 42 | cloudcontrol.GetResourceOutput, |
| 43 | cloudcontrol.GetResourceError |
| 44 | > |
| 45 | > |
| 46 | > {} |
| 47 | |
| 48 | export const GetResource = Binding.Service<GetResource>( |
| 49 | "AWS.CloudControl.GetResource", |
| 50 | ); |