Skip to content

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:

  1. be attached to the cluster’s VPC (vpc: { subnetIds, securityGroupIds } or the binding’s subnetIds/securityGroupIds options), and
  2. 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).

// init — publishes env vars, grants memorydb:Connect, attaches the VPC
const 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;