| 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:ListResources`. |
| 8 | * |
| 9 | * Discovers resources of a given CloudFormation type in the account and |
| 10 | * Region — whether or not they were provisioned through Cloud Control. |
| 11 | * Because Cloud Control invokes the resource type's list handler with the |
| 12 | * caller's credentials, pass the handler's underlying permissions via |
| 13 | * {@link CloudControlBindingOptions.handlerPolicyStatements}. |
| 14 | * ### Reading Resources |
| 15 | * **Example:** List SSM Parameters |
| 16 | * ```typescript |
| 17 | * // init — account-level; grant the list handler's permissions too |
| 18 | * const listResources = yield* CloudControl.ListResources({ |
| 19 | * handlerPolicyStatements: [ |
| 20 | * { Effect: "Allow", Action: ["ssm:DescribeParameters"], Resource: ["*"] }, |
| 21 | * ], |
| 22 | * }); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const page = yield* listResources({ |
| 26 | * TypeName: "AWS::SSM::Parameter", |
| 27 | * MaxResults: 100, |
| 28 | * }); |
| 29 | * const identifiers = (page.ResourceDescriptions ?? []).map((r) => r.Identifier); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface ListResources extends Binding.Service< |
| 35 | ListResources, |
| 36 | "AWS.CloudControl.ListResources", |
| 37 | ( |
| 38 | options?: CloudControlBindingOptions, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: cloudcontrol.ListResourcesInput, |
| 42 | ) => Effect.Effect< |
| 43 | cloudcontrol.ListResourcesOutput, |
| 44 | cloudcontrol.ListResourcesError |
| 45 | > |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const ListResources = Binding.Service<ListResources>( |
| 50 | "AWS.CloudControl.ListResources", |
| 51 | ); |