In localstack-pro-samples iot-basics example is using this lib paho.mqtt.client for creating an mqtt client:
paho.mqtt.client. This is not AWS best practice.
The following code is the way to do it:
event_loop_group = io.EventLoopGroup(1)
host_resolver = io.DefaultHostResolver(event_loop_group)
client_bootstrap = io.ClientBootstrap(event_loop_group, host_resolver)
mqtt_client = mqtt_connection_builder.mtls_from_path(
endpoint=config.iot_endpoint,
cert_filepath=claim_cert_path,
pri_key_filepath=secure_key_path,
client_bootstrap=client_bootstrap,
ca_filepath=root_cert_path,
on_connection_interrupted=self.on_connection_interrupted,
on_connection_resumed=self.on_connection_resumed,
client_id="my_client,
clean_session=False,
keep_alive_secs=6)
connect_future = mqtt_client.connect()