Skip to content

AWS.MQ reference

Source: src/AWS/MQ/Broker.ts

An Amazon MQ broker — a managed message broker running Apache ActiveMQ or RabbitMQ. Amazon MQ handles provisioning, patching, and (for multi-AZ deployments) failover, exposing standard wire protocols (OpenWire, AMQP, MQTT, STOMP, WSS) so existing clients connect unchanged.

Broker creation and deletion are asynchronous and take several minutes; the provider waits (bounded) for the broker to reach RUNNING before returning, and waits for it to disappear on delete.

Single-instance ActiveMQ (cheapest)

const broker = yield* MQ.Broker("Orders", {
engineType: "ACTIVEMQ",
engineVersion: "5.18",
hostInstanceType: "mq.t3.micro",
deploymentMode: "SINGLE_INSTANCE",
publiclyAccessible: true,
users: [{ username: "admin", password: Redacted.make("SuperSecretPassw0rd") }],
});
// broker.endpoints -> ["ssl://b-xxxx-1.mq.us-west-2.amazonaws.com:61617", ...]

Single-instance RabbitMQ

const broker = yield* MQ.Broker("Events", {
engineType: "RABBITMQ",
engineVersion: "3.13",
hostInstanceType: "mq.t3.micro",
publiclyAccessible: true,
users: [{ username: "admin", password: Redacted.make("SuperSecretPassw0rd") }],
});
const broker = yield* MQ.Broker("Orders", {
engineType: "ACTIVEMQ",
engineVersion: "5.18",
hostInstanceType: "mq.m5.large",
deploymentMode: "ACTIVE_STANDBY_MULTI_AZ",
publiclyAccessible: false,
subnetIds: [subnetA.subnetId, subnetB.subnetId],
securityGroups: [group.groupId],
encryptionOptions: { kmsKeyId: key.keyArn },
users: [{ username: "admin", password: Redacted.make("SuperSecretPassw0rd") }],
});
const broker = yield* MQ.Broker("Orders", {
engineType: "ACTIVEMQ",
engineVersion: "5.18",
hostInstanceType: "mq.t3.micro",
users: [{ username: "admin", password: Redacted.make("SuperSecretPassw0rd") }],
logs: { general: true, audit: true },
maintenanceWindow: {
dayOfWeek: "SUNDAY",
timeOfDay: "03:00",
timeZone: "UTC",
},
});

Subscribe a Lambda function to broker queues from the init phase via consumeBrokerMessages. The event-source mapping, IAM grants, and runtime dispatch are created automatically (provide Lambda.BrokerEventSource on the function).

// init
yield* MQ.consumeBrokerMessages(
broker,
{
queues: ["orders"],
credentialsSecretArn: secret.secretArn,
},
(messages) =>
messages.pipe(
Stream.runForEach((message) =>
Effect.log(`received: ${message.data}`),
),
),
);

Source: src/AWS/MQ/BrokerEventSource.ts

Event source connecting an Amazon MQ Broker to the hosting Lambda function. Prefer the consumeBrokerMessages helper; this service is the underlying contract, implemented by the Lambda.BrokerEventSource layer (which registers the event-source mapping, IAM grants, and runtime dispatch).

// equivalent to consumeBrokerMessages(broker, props, process)
yield* BrokerEventSource.use((source) =>
source(broker, props, process),
);

Source: src/AWS/MQ/Configuration.ts

An Amazon MQ broker configuration — a versioned document (ActiveMQ XML or RabbitMQ Cuttlefish) that a Broker can reference to control engine-level settings. Each edit to data publishes a new immutable revision; a broker pins a specific { id, revision } pair.

Default ActiveMQ Configuration

const config = yield* MQ.Configuration("BrokerConfig", {
engineType: "ACTIVEMQ",
engineVersion: "5.18",
});

Custom ActiveMQ Configuration Document

const config = yield* MQ.Configuration("BrokerConfig", {
engineType: "ACTIVEMQ",
engineVersion: "5.18",
description: "Enable statistics plugin",
data: `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<broker xmlns="http://activemq.apache.org/schema/core">
<plugins>
<statisticsBrokerPlugin/>
</plugins>
</broker>`,
});
// config.configurationRevision -> 2 (the published revision)
const broker = yield* MQ.Broker("Orders", {
engineType: "ACTIVEMQ",
engineVersion: "5.18",
hostInstanceType: "mq.t3.micro",
users: [{ username: "admin", password: Redacted.make("SuperSecretPassw0rd") }],
configuration: {
id: config.configurationId,
revision: config.configurationRevision,
},
});

Source: src/AWS/MQ/CreateUser.ts

Runtime binding for the CreateUser operation (IAM action mq:CreateUser), scoped to one Broker.

Creates a broker user — e.g. provisioning per-tenant credentials at runtime. On ActiveMQ the change is staged and applied at the next broker reboot or maintenance window; on RabbitMQ it takes effect immediately. The password is marked sensitive — pass a Redacted value and it stays redacted until wire encoding. Provide the implementation with Effect.provide(AWS.MQ.CreateUserHttp).

const createUser = yield* MQ.CreateUser(broker);
yield* createUser({
Username: "tenant-42",
Password: Redacted.make("SuperSecretPassw0rd"),
});

Source: src/AWS/MQ/DeleteUser.ts

Runtime binding for the DeleteUser operation (IAM action mq:DeleteUser), scoped to one Broker.

Deletes a broker user — e.g. revoking per-tenant credentials at runtime. On ActiveMQ the change is staged and applied at the next broker reboot or maintenance window; on RabbitMQ it takes effect immediately. Provide the implementation with Effect.provide(AWS.MQ.DeleteUserHttp).

const deleteUser = yield* MQ.DeleteUser(broker);
yield* deleteUser({ Username: "tenant-42" });

Source: src/AWS/MQ/DescribeBroker.ts

Runtime binding for the DescribeBroker operation (IAM action mq:DescribeBroker), scoped to one Broker.

Resolves the broker’s live state at runtime — engine version, instance endpoints (the wire-protocol URIs clients connect to), pending changes, and maintenance information. Provide the implementation with Effect.provide(AWS.MQ.DescribeBrokerHttp).

const describeBroker = yield* MQ.DescribeBroker(broker);
const info = yield* describeBroker();
// info.BrokerState → "RUNNING"
// info.BrokerInstances?.[0]?.Endpoints → ["ssl://b-….mq.us-west-2.amazonaws.com:61617", …]

Source: src/AWS/MQ/DescribeUser.ts

Runtime binding for the DescribeUser operation (IAM action mq:DescribeUser), scoped to one Broker.

Reads a broker user’s attributes — console access, groups, and any pending change staged for the next reboot. Provide the implementation with Effect.provide(AWS.MQ.DescribeUserHttp).

const describeUser = yield* MQ.DescribeUser(broker);
const user = yield* describeUser({ Username: "tenant-42" });
// user.Groups, user.Pending?.PendingChange → "CREATE" | "UPDATE" | "DELETE"

Source: src/AWS/MQ/ListBrokers.ts

Runtime binding for the ListBrokers operation (IAM action mq:ListBrokers on * — the operation is not resource-scoped).

Lists all Amazon MQ brokers in the account/region. Provide the implementation with Effect.provide(AWS.MQ.ListBrokersHttp).

const listBrokers = yield* MQ.ListBrokers();
const page = yield* listBrokers();
// page.BrokerSummaries → [{ BrokerName: "orders", BrokerState: "RUNNING", … }]

Source: src/AWS/MQ/ListUsers.ts

Runtime binding for the ListUsers operation (IAM action mq:ListUsers), scoped to one Broker.

Lists all users on the broker, including any with staged pending changes. Provide the implementation with Effect.provide(AWS.MQ.ListUsersHttp).

const listUsers = yield* MQ.ListUsers(broker);
const page = yield* listUsers();
// page.Users → [{ Username: "admin" }, { Username: "tenant-42", PendingChange: "CREATE" }]

Source: src/AWS/MQ/Promote.ts

Runtime binding for the Promote operation (IAM action mq:Promote), scoped to one Broker.

Promotes a cross-region data replication (CRDR) replica broker to the primary role — SWITCHOVER performs a coordinated role exchange with the current primary, FAILOVER promotes the replica unilaterally when the primary is unreachable. Only meaningful for brokers created with dataReplicationMode: "CRDR". Provide the implementation with Effect.provide(AWS.MQ.PromoteHttp).

const promote = yield* MQ.Promote(replica);
yield* promote({ Mode: "FAILOVER" });

Source: src/AWS/MQ/RebootBroker.ts

Runtime binding for the RebootBroker operation (IAM action mq:RebootBroker), scoped to one Broker.

Reboots the broker to apply pending modifications (engine version, host instance type, configuration revision, user changes). The reboot is asynchronous — the broker transitions through REBOOT_IN_PROGRESS back to RUNNING. Provide the implementation with Effect.provide(AWS.MQ.RebootBrokerHttp).

const rebootBroker = yield* MQ.RebootBroker(broker);
yield* rebootBroker();

Source: src/AWS/MQ/UpdateUser.ts

Runtime binding for the UpdateUser operation (IAM action mq:UpdateUser), scoped to one Broker.

Updates a broker user’s password, console access, or groups — e.g. rotating credentials at runtime. On ActiveMQ the change is staged and applied at the next broker reboot or maintenance window; on RabbitMQ it takes effect immediately. Provide the implementation with Effect.provide(AWS.MQ.UpdateUserHttp).

const updateUser = yield* MQ.UpdateUser(broker);
yield* updateUser({
Username: "tenant-42",
Password: Redacted.make("NewSecretPassw0rd"),
});