InfluxDB: 4. Create the service

This documentation is part of the Automate with the CLI guide. You can view the complete guide here: Start InfluxDB, retrieve its credentials, and modify its configuration programmatically using the Stackhero CLI.

👋 Welcome to the Stackhero documentation

Stackhero provides a fully managed InfluxDB cloud environment, designed for speed and simplicity:

  • Unlimited writes, queries, dashboards, tasks, and buckets.
  • Unlimited data retention: keep your metrics for as long as you need.
  • Unlimited network and disk transfers, with no hidden limits.
  • One-click updates: always benefit from the latest features and fixes.
  • Consistent performance and enhanced security on your own private, dedicated infrastructure.

With Stackhero, you can focus on your data and analysis. Deploying InfluxDB cloud hosting only takes a few minutes, with every setup optimised for long-term reliability.

Below is an example script that creates a stack, adds your InfluxDB 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="influxdb"   # The InfluxDB 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 InfluxDB stack")
echo "Stack created: ${stackId}"

# Add InfluxDB to the stack (names are resolved automatically)
serviceId=$(stackhero --format=script service-add \
  --stack="My InfluxDB stack" \
  --service-store="${serviceStore}" \
  --instance="${instance}" \
  --region="${region}")
echo "Service added: influxdb"

# Wait for the service to be fully operational (this may take a few minutes)
stackhero service-wait-for --service="influxdb"

# Retrieve the service configuration, including generated credentials
stackhero service-configuration-get --service="influxdb" --format=json