createBroker method

Future<CreateBrokerResponse> createBroker({
  1. required String brokerName,
  2. required DeploymentMode deploymentMode,
  3. required EngineType engineType,
  4. required String hostInstanceType,
  5. required bool publiclyAccessible,
  6. AuthenticationStrategy? authenticationStrategy,
  7. bool? autoMinorVersionUpgrade,
  8. ConfigurationId? configuration,
  9. String? creatorRequestId,
  10. DataReplicationMode? dataReplicationMode,
  11. String? dataReplicationPrimaryBrokerArn,
  12. EncryptionOptions? encryptionOptions,
  13. String? engineVersion,
  14. LdapServerMetadataInput? ldapServerMetadata,
  15. Logs? logs,
  16. WeeklyStartTime? maintenanceWindowStartTime,
  17. List<String>? securityGroups,
  18. BrokerStorageType? storageType,
  19. List<String>? subnetIds,
  20. Map<String, String>? tags,
  21. List<User>? users,
})

Creates a broker. Note: This API is asynchronous.

To create a broker, you must either use the AmazonMQFullAccess IAM policy or include the following EC2 permissions in your IAM policy.

  • ec2:CreateNetworkInterface

    This permission is required to allow Amazon MQ to create an elastic network interface (ENI) on behalf of your account.

  • ec2:CreateNetworkInterfacePermission

    This permission is required to attach the ENI to the broker instance.

  • ec2:DeleteNetworkInterface
  • ec2:DeleteNetworkInterfacePermission
  • ec2:DetachNetworkInterface
  • ec2:DescribeInternetGateways
  • ec2:DescribeNetworkInterfaces
  • ec2:DescribeNetworkInterfacePermissions
  • ec2:DescribeRouteTables
  • ec2:DescribeSecurityGroups
  • ec2:DescribeSubnets
  • ec2:DescribeVpcs
For more information, see Create an IAM User and Get Your Amazon Web Services Credentials and Never Modify or Delete the Amazon MQ Elastic Network Interface in the Amazon MQ Developer Guide.

May throw BadRequestException. May throw ConflictException. May throw ForbiddenException. May throw InternalServerErrorException. May throw UnauthorizedException.

Parameter brokerName : Required. The broker's name. This value must be unique in your Amazon Web Services account, 1-50 characters long, must contain only letters, numbers, dashes, and underscores, and must not contain white spaces, brackets, wildcard characters, or special characters.

Parameter deploymentMode : Required. The broker's deployment mode.

Parameter engineType : Required. The type of broker engine. Currently, Amazon MQ supports ACTIVEMQ and RABBITMQ.

Parameter hostInstanceType : Required. The broker's instance type.

Parameter publiclyAccessible : Enables connections from applications outside of the VPC that hosts the broker's subnets. Set to false by default, if no value is provided.

Parameter authenticationStrategy : Optional. The authentication strategy used to secure the broker. The default is SIMPLE.

Parameter autoMinorVersionUpgrade : Enables automatic upgrades to new patch versions for brokers as new versions are released and supported by Amazon MQ. Automatic upgrades occur during the scheduled maintenance window or after a manual broker reboot. Set to true by default, if no value is specified.

Parameter configuration : A list of information about the configuration.

Parameter creatorRequestId : The unique ID that the requester receives for the created broker. Amazon MQ passes your ID with the API action.

Parameter dataReplicationMode : Defines whether this broker is a part of a data replication pair.

Parameter dataReplicationPrimaryBrokerArn : The Amazon Resource Name (ARN) of the primary broker that is used to replicate data from in a data replication pair, and is applied to the replica broker. Must be set when dataReplicationMode is set to CRDR.

Parameter encryptionOptions : Encryption options for the broker.

Parameter engineVersion : The broker engine version. Defaults to the latest available version for the specified broker engine type. For more information, see the ActiveMQ version management and the RabbitMQ version management sections in the Amazon MQ Developer Guide.

Parameter ldapServerMetadata : Optional. The metadata of the LDAP server used to authenticate and authorize connections to the broker. Does not apply to RabbitMQ brokers.

Parameter logs : Enables Amazon CloudWatch logging for brokers.

Parameter maintenanceWindowStartTime : The parameters that determine the WeeklyStartTime.

Parameter securityGroups : The list of rules (1 minimum, 125 maximum) that authorize connections to brokers.

Parameter storageType : The broker's storage type.

Parameter subnetIds : The list of groups that define which subnets and IP ranges the broker can use from different Availability Zones. If you specify more than one subnet, the subnets must be in different Availability Zones. Amazon MQ will not be able to create VPC endpoints for your broker with multiple subnets in the same Availability Zone. A SINGLE_INSTANCE deployment requires one subnet (for example, the default subnet). An ACTIVE_STANDBY_MULTI_AZ Amazon MQ for ActiveMQ deployment requires two subnets. A CLUSTER_MULTI_AZ Amazon MQ for RabbitMQ deployment has no subnet requirements when deployed with public accessibility. Deployment without public accessibility requires at least one subnet.

Parameter tags : Create tags when creating the broker.

Parameter users : The list of broker users (persons or applications) who can access queues and topics. For Amazon MQ for RabbitMQ brokers, an administrative user is required if using simple authentication and authorization. For brokers using OAuth2, this user is optional. When provided, one and only one administrative user is accepted and created when a broker is first provisioned. All subsequent broker users are created by making RabbitMQ API calls directly to brokers or via the RabbitMQ web console.

Implementation

Future<CreateBrokerResponse> createBroker({
  required String brokerName,
  required DeploymentMode deploymentMode,
  required EngineType engineType,
  required String hostInstanceType,
  required bool publiclyAccessible,
  AuthenticationStrategy? authenticationStrategy,
  bool? autoMinorVersionUpgrade,
  ConfigurationId? configuration,
  String? creatorRequestId,
  DataReplicationMode? dataReplicationMode,
  String? dataReplicationPrimaryBrokerArn,
  EncryptionOptions? encryptionOptions,
  String? engineVersion,
  LdapServerMetadataInput? ldapServerMetadata,
  Logs? logs,
  WeeklyStartTime? maintenanceWindowStartTime,
  List<String>? securityGroups,
  BrokerStorageType? storageType,
  List<String>? subnetIds,
  Map<String, String>? tags,
  List<User>? users,
}) async {
  final $payload = <String, dynamic>{
    'brokerName': brokerName,
    'deploymentMode': deploymentMode.value,
    'engineType': engineType.value,
    'hostInstanceType': hostInstanceType,
    'publiclyAccessible': publiclyAccessible,
    if (authenticationStrategy != null)
      'authenticationStrategy': authenticationStrategy.value,
    if (autoMinorVersionUpgrade != null)
      'autoMinorVersionUpgrade': autoMinorVersionUpgrade,
    if (configuration != null) 'configuration': configuration,
    'creatorRequestId': creatorRequestId ?? _s.generateIdempotencyToken(),
    if (dataReplicationMode != null)
      'dataReplicationMode': dataReplicationMode.value,
    if (dataReplicationPrimaryBrokerArn != null)
      'dataReplicationPrimaryBrokerArn': dataReplicationPrimaryBrokerArn,
    if (encryptionOptions != null) 'encryptionOptions': encryptionOptions,
    if (engineVersion != null) 'engineVersion': engineVersion,
    if (ldapServerMetadata != null) 'ldapServerMetadata': ldapServerMetadata,
    if (logs != null) 'logs': logs,
    if (maintenanceWindowStartTime != null)
      'maintenanceWindowStartTime': maintenanceWindowStartTime,
    if (securityGroups != null) 'securityGroups': securityGroups,
    if (storageType != null) 'storageType': storageType.value,
    if (subnetIds != null) 'subnetIds': subnetIds,
    if (tags != null) 'tags': tags,
    if (users != null) 'users': users,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/brokers',
    exceptionFnMap: _exceptionFns,
  );
  return CreateBrokerResponse.fromJson(response);
}