| 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:UpdateResource`. |
| 8 | * |
| 9 | * Applies an RFC 6902 JSON Patch to an existing resource's properties. The |
| 10 | * call is asynchronous: poll the returned `RequestToken` with |
| 11 | * {@link GetResourceRequestStatus} until the operation settles. Because Cloud |
| 12 | * Control invokes the resource type's update handler with the caller's |
| 13 | * credentials, pass the handler's underlying permissions via |
| 14 | * {@link CloudControlBindingOptions.handlerPolicyStatements}. |
| 15 | * ### Provisioning Resources |
| 16 | * **Example:** Patch an SSM Parameter's value |
| 17 | * ```typescript |
| 18 | * const updateResource = yield* CloudControl.UpdateResource({ |
| 19 | * handlerPolicyStatements: [ |
| 20 | * { |
| 21 | * Effect: "Allow", |
| 22 | * Action: ["ssm:PutParameter", "ssm:GetParameters"], |
| 23 | * Resource: ["*"], |
| 24 | * }, |
| 25 | * ], |
| 26 | * }); |
| 27 | * |
| 28 | * // runtime |
| 29 | * const updated = yield* updateResource({ |
| 30 | * TypeName: "AWS::SSM::Parameter", |
| 31 | * Identifier: "/tenants/acme/greeting", |
| 32 | * PatchDocument: JSON.stringify([ |
| 33 | * { op: "replace", path: "/Value", value: "howdy" }, |
| 34 | * ]), |
| 35 | * }); |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface UpdateResource extends Binding.Service< |
| 41 | UpdateResource, |
| 42 | "AWS.CloudControl.UpdateResource", |
| 43 | ( |
| 44 | options?: CloudControlBindingOptions, |
| 45 | ) => Effect.Effect< |
| 46 | ( |
| 47 | request: cloudcontrol.UpdateResourceInput, |
| 48 | ) => Effect.Effect< |
| 49 | cloudcontrol.UpdateResourceOutput, |
| 50 | cloudcontrol.UpdateResourceError |
| 51 | > |
| 52 | > |
| 53 | > {} |
| 54 | |
| 55 | export const UpdateResource = Binding.Service<UpdateResource>( |
| 56 | "AWS.CloudControl.UpdateResource", |
| 57 | ); |