| 1 | import * as appintegrations from "@distilled.cloud/aws/appintegrations"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import * as Output from "../../Output.ts"; |
| 4 | import { makeAppIntegrationsHttpBinding } from "./BindingHttp.ts"; |
| 5 | import type { DataIntegration } from "./DataIntegration.ts"; |
| 6 | import { UpdateDataIntegrationAssociation } from "./UpdateDataIntegrationAssociation.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link UpdateDataIntegrationAssociation}. At deploy |
| 10 | * time it grants `app-integrations:UpdateDataIntegrationAssociation` on the |
| 11 | * data integration (and its `data-integration-association/*` children); at |
| 12 | * runtime it calls the AppIntegrations API with the host Function's |
| 13 | * credentials, injecting the data integration's id. Provide this layer on |
| 14 | * the Function using the binding. |
| 15 | */ |
| 16 | export const UpdateDataIntegrationAssociationHttp = Layer.effect( |
| 17 | UpdateDataIntegrationAssociation, |
| 18 | makeAppIntegrationsHttpBinding({ |
| 19 | name: "UpdateDataIntegrationAssociation", |
| 20 | operation: appintegrations.updateDataIntegrationAssociation, |
| 21 | requestKey: "DataIntegrationIdentifier", |
| 22 | identifier: (integration: DataIntegration) => integration.dataIntegrationId, |
| 23 | iamActions: ["app-integrations:UpdateDataIntegrationAssociation"], |
| 24 | resources: (integration, { region, accountId }) => [ |
| 25 | Output.interpolate`${integration.dataIntegrationArn}`, |
| 26 | Output.interpolate`arn:aws:app-integrations:${region}:${accountId}:data-integration-association/${integration.dataIntegrationId}/*`, |
| 27 | ], |
| 28 | // Rerunning the on-demand job snapshots through Customer Profiles on the |
| 29 | // caller's behalf. |
| 30 | dependentActions: ["profile:CreateSnapshot", "profile:GetSnapshot"], |
| 31 | }), |
| 32 | ); |