Voorbeeld: Een service end-to-end aanmaken
Deze documentatie maakt deel uit van de De CLI gebruiken-gids. Bekijk de volledige gids hier: Installeer en gebruik de Stackhero CLI om uw stacks en services te beheren vanaf de command line, scripts, CI en AI-agents.
Hier is een voorbeeldscript dat laat zien hoe u een stack kunt aanmaken, een service kunt toevoegen, kunt wachten tot die klaar is en de credentials kunt ophalen. Dit voorbeeld is volledig niet-interactief en gebruikt de omgevingsvariabele STACKHERO_TOKEN.
#!/bin/bash
set -e
export STACKHERO_TOKEN="usr-xxxxxx:your-token"
serviceStore="directus" # A service store name. See: `stackhero services-store-list`
instance="1GB" # An instance (size) name. See: `stackhero instances-store-list --service-store=directus`
region="europe" # A region name. See: `stackhero regions-list`
# Create a stack (uses your only organization, add `--organization` if you have several)
stackId=$(stackhero --format=script stack-create \
--name="My stack")
echo "Stack: ${stackId}"
# Add a service (names are resolved automatically, and the stack ID above also works)
serviceId=$(stackhero --format=script service-add \
--stack="My stack" \
--service-store="${serviceStore}" \
--instance="${instance}" \
--region="${region}")
echo "Service: ${serviceId}"
# Wait for the service to be running
stackhero service-wait-for --service="${serviceId}"
# Retrieve credentials and configuration
stackhero service-configuration-get --service="${serviceId}" --format=json
Elke servicedocumentatiepagina bevat een kant-en-klare gids Automate with the CLI die op die service is afgestemd, zodat u alles hebt wat u nodig hebt om aan de slag te gaan.