Python: 4. Create the service

This documentation is part of the Automate with the CLI guide. View the full guide here: Start Python, retrieve its credentials, and change its configuration programmatically with the Stackhero CLI.

👋 Welcome to the Stackhero documentation!

Stackhero provides a ready-to-use Python cloud solution designed to streamline your deployment process:

  • Deploy your application to production in seconds with a simple git push.
  • Use your own domain name, with automatic HTTPS certificate configuration for secure connections handled for you.
  • Rely on automatic backups, one-click updates, and predictable pricing, so you can focus on your code, not infrastructure management.
  • Benefit from strong performance and security on a private, dedicated infrastructure. Your environment is isolated and protected.

Save time and simplify your workflow: you can have your code running with Stackhero's Python cloud hosting in just 5 minutes.

Here is a sample script that creates a stack, adds your Python 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="python"   # The Python 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 organization; add --organization if needed)
stackId=$(stackhero --format=script stack-create \
  --name="My Python stack")
echo "Stack created: ${stackId}"

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

# Wait for the service to be fully running (this may take a couple of minutes)
stackhero service-wait-for --service="python"

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