| 1 | import * as ga from "@distilled.cloud/aws/global-accelerator"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import { AddEndpoints } from "./AddEndpoints.ts"; |
| 4 | import { makeGaEndpointGroupHttpBinding } from "./BindingHttp.ts"; |
| 5 | |
| 6 | export const AddEndpointsHttp = Layer.effect( |
| 7 | AddEndpoints, |
| 8 | makeGaEndpointGroupHttpBinding({ |
| 9 | tag: "AWS.GlobalAccelerator.AddEndpoints", |
| 10 | operation: ga.addEndpoints, |
| 11 | // Global Accelerator authorizes AddEndpoints as an update to the |
| 12 | // endpoint group ("not authorized to perform: |
| 13 | // globalaccelerator:UpdateEndpointGroup" when only AddEndpoints is |
| 14 | // granted), so both actions are required. |
| 15 | actions: [ |
| 16 | "globalaccelerator:AddEndpoints", |
| 17 | "globalaccelerator:UpdateEndpointGroup", |
| 18 | ], |
| 19 | // Global Accelerator validates new endpoints by describing them on the |
| 20 | // caller's behalf, so adding endpoints requires read access to the |
| 21 | // underlying EC2 / ELB resources (none support resource-level scoping). |
| 22 | // https://docs.aws.amazon.com/global-accelerator/latest/dg/security_iam_service-with-iam.html |
| 23 | extraStatements: [ |
| 24 | { |
| 25 | Effect: "Allow", |
| 26 | Action: [ |
| 27 | "ec2:DescribeAddresses", |
| 28 | "ec2:DescribeInstances", |
| 29 | "ec2:DescribeInternetGateways", |
| 30 | "ec2:DescribeSubnets", |
| 31 | "elasticloadbalancing:DescribeLoadBalancers", |
| 32 | ], |
| 33 | Resource: ["*"], |
| 34 | }, |
| 35 | ], |
| 36 | }), |
| 37 | ); |