Mosquitto: 4. Create the service
This documentation is part of the Automate with the CLI guide. You can view the complete guide here: Start Mosquitto, retrieve its credentials, and modify its configuration programmatically using the Stackhero CLI.
👋 Welcome to the Stackhero documentation!
Stackhero provides you with a fully managed Mosquitto MQTT cloud environment, designed for reliability and flexibility:
- Unlimited message throughput and data transfers, so your workflows never encounter artificial limits.
- Unlimited device authentication via your own external API, making onboarding and access management straightforward.
- Advanced ACLs for precise control over topics, users, and actions.
- A custom domain name with integrated HTTPS for secure, branded endpoints (for example: https://mqtt.your-company.com).
- Effortless updates: apply improvements or security patches with a single click.
- Consistent performance and enhanced security, with every instance running on a private, dedicated infrastructure.
Accelerate your IoT projects and reduce operational overhead. You can have a secure, production-ready Mosquitto MQTT cloud hosting instance up and running in just a few minutes.
Below is an example script that creates a stack, adds your Mosquitto service to it, waits for it to start, retrieves its configuration (including generated credentials), and then applies a new configuration.
#!/bin/bash
set -e
export STACKHERO_TOKEN="usr-xxxxxx:your-token"
serviceStore="mosquitto" # The Mosquitto service store name (see step 2)
instance="..." # An instance size from step 3
region="europe" # A region name from step 3
# Create a stack for your service (uses your default organisation; add --organization if needed)
stackId=$(stackhero --format=script stack-create \
--name="My Mosquitto stack")
echo "Stack created: ${stackId}"
# Add Mosquitto to the stack (names are resolved automatically)
serviceId=$(stackhero --format=script service-add \
--stack="My Mosquitto stack" \
--service-store="${serviceStore}" \
--instance="${instance}" \
--region="${region}")
echo "Service added: mosquitto"
# Wait for the service to be fully operational (this may take a few minutes)
stackhero service-wait-for --service="mosquitto"
# Retrieve the service configuration, including generated credentials
stackhero service-configuration-get --service="mosquitto" --format=json