Manage Cloud with Terraform
Manage your Cloud servers, firewalls and SSH keys as code with the Better Stack Terraform provider, BetterStackHQ/betterstack.
Get an API token
Create a global API token in Settings → API tokens → Global tokens, and set it as the BETTERSTACK_API_TOKEN environment variable in the shell that runs Terraform.
Configure the provider
Each data center is managed separately, so set the one your resources are in as availability_zone:
Create your first server
Add your SSH key, a firewall that lets in SSH and HTTPS, and a server that uses both. Replace t123 with your team's ID from betterstack team list in the Cloud CLI:
Connect as root:
A firewall created this way has no inbound rules of its own, so keep the SSH rule to reach the server.
Removing a server?
Servers start with deletion_protection = true. To remove one with terraform destroy, set deletion_protection = false and run terraform apply first.
Import existing resources
Bring a server you created in the dashboard or the CLI under Terraform with an import block. Find its ID in the ID column:
Write its configuration, then apply:
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏