| 1 | import * as cloudfunctions from "@distilled.cloud/gcp/cloudfunctions_v2"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import { makeFunctionHttpBinding } from "./BindingHttp.ts"; |
| 4 | import { GetFunction } from "./GetFunction.ts"; |
| 5 | |
| 6 | /** |
| 7 | * HTTP implementation of {@link GetFunction}. |
| 8 | * |
| 9 | * @layer |
| 10 | * @provides GCP.CloudFunctions.GetFunction |
| 11 | */ |
| 12 | export const GetFunctionHttp = Layer.effect( |
| 13 | GetFunction, |
| 14 | makeFunctionHttpBinding({ |
| 15 | tag: "GCP.CloudFunctions.GetFunction", |
| 16 | // 2nd gen functions accept only invoker roles on their own IAM policy |
| 17 | // (anything else is INVALID_ARGUMENT), so grant on the project under a |
| 18 | // condition naming the function. |
| 19 | iam: { role: "roles/cloudfunctions.viewer", scopeByCondition: true }, |
| 20 | operation: cloudfunctions.getProjectsLocationsFunctions, |
| 21 | }), |
| 22 | ); |