Connect
Source:
src/AWS/MemoryDB/Connect.ts
Runtime binding that resolves connection settings for a MemoryDB
Cluster.
At deploy time it publishes the cluster endpoint as
MEMORYDB_{LOGICAL_ID}_{HOST,PORT,TLS} environment variables on the host
Function and grants memorydb:Connect on the cluster (plus any IAM-auth
Users passed via options.users); at runtime it resolves the same
values into a typed ClusterConnectionInfo. Network access is
governed by VPC security groups — the host Function must:
- be attached to the cluster’s VPC (
vpc: { subnetIds, securityGroupIds }or the binding’ssubnetIds/securityGroupIdsoptions), and - have a security group allowed ingress on the cluster’s port by one of
the cluster’s
securityGroupIds.
Provide the implementation with Effect.provide(AWS.MemoryDB.ConnectHttp).
Connecting to a Cluster
Section titled “Connecting to a Cluster”// init — publishes env vars, grants memorydb:Connect, attaches the VPCconst connect = yield* AWS.MemoryDB.Connect(cluster, { users: [appUser], subnetIds: [subnetA.subnetId, subnetB.subnetId], securityGroupIds: [appSecurityGroup.groupId],});
// inside a handler:const { host, port, tls } = yield* connect;