suga build. This page explains the deployment lifecycle, how to deploy to different environments, and best practices for production deployments.
Deployment Overview
Suga’s deployment model is transparent and uses standard tools:- Generate Terraform -
suga buildcreates Terraform modules - Configure Provider - Set up cloud provider credentials and configuration
- Initialize Terraform - Download providers and modules
- Preview Changes - Review what will be created/modified
- Apply Changes - Deploy to your cloud provider
- Verify Deployment - Test deployed resources
The Deployment Lifecycle
1
Build Infrastructure
Generate Terraform from your project:Output:
2
Navigate to Stack
Change to the generated Terraform directory:Contents:
3
Configure Cloud Provider
Set up provider configuration and credentials:Create provider configuration:
- AWS
- GCP
provider.tf
Files like
provider.tf and terraform.tfvars are preserved across builds and won’t be overwritten.4
Initialize Terraform
Download providers and modules:This downloads:
- Cloud provider Terraform providers (AWS, GCP, etc.)
- Plugin modules referenced by your platform
- Backend configuration (if configured)
5
Preview Changes
Review what Terraform will create:Output shows:
- Resources to be created (
+) - Resources to be modified (
~) - Resources to be deleted (
-)
6
Deploy
Apply the Terraform configuration:Terraform will:
- Show the plan again
- Ask for confirmation
- Create resources in your cloud account
- Save state to track resources
7
Verify Deployment
Test your deployed application:
Managing Deployments
Updating Your Application
When you make changes to your project:-
Rebuild Terraform:
-
Preview changes:
-
Apply updates:
- Modified services are redeployed
- New resources are created
- Removed resources are deleted
- Unchanged resources remain untouched
Deploying Code Updates
When you update service code without changing infrastructure:- Builds new container images from your updated code
- Pushes images to the container registry (ECR, Artifact Registry, etc.)
- Updates services to use the new images
- Handles rolling deployments with zero downtime
CI/CD pipelines typically automate this by running
terraform apply on every commit. See the CI/CD Authentication Guide for details.Rolling Back
If a deployment causes issues, roll back:Destroying Resources
When you’re done with a deployment:Multi-Environment Deployments
Deploy the same application to multiple environments (dev, staging, production) using Terraform workspaces and environment-specific variable files. This allows you to maintain a single infrastructure definition while customizing configuration per environment.Terraform Environment Management
Learn how to manage multiple environments with Terraform workspaces and variables
Cloud Provider Setup
Each cloud provider requires specific credentials and permissions. Detailed setup instructions including required permissions, authentication methods, and provider configuration are available in the provider-specific guides:AWS Deployment
AWS credentials, IAM permissions, and configuration
GCP Deployment
GCP service accounts, permissions, and configuration
Azure Deployment
Azure credentials, RBAC, and configuration
Terraform State Management
Terraform state tracks deployed resources and must be managed carefully. By default, state is stored locally, which is suitable for personal projects but not recommended for teams. For production deployments, use a remote backend for state locking, versioning, and team collaboration.Terraform Backend Configuration
Complete guide to configuring remote state backends (S3, GCS, Terraform Cloud)
CI/CD Integration
Automate deployments with CI/CD pipelines to build infrastructure and deploy on every commit. Common patterns include GitHub Actions, GitLab CI, CircleCI, and Jenkins.CI/CD Authentication Guide
Learn how to authenticate Suga in CI/CD pipelines with example workflows
Best Practices
1. Always Preview Before Applying
2. Use Remote State for Teams
Configure a remote backend for team deployments. See the Terraform Backend Configuration guide.3. Separate Environments
Use Terraform workspaces or separate state files. See the Environment Management docs.4. Version Control Everything
Commit generated Terraform to git:5. Test in Non-Production First
Always deploy to dev/staging before production:6. Use Terraform Variables for Configuration
Use variable files for environment-specific configuration. See the Terraform Configuration guide.7. Monitor Deployments
Set up monitoring for deployed resources:- CloudWatch (AWS)
- Cloud Monitoring (GCP)
- Application Performance Monitoring (APM) tools
8. Document Your Deployments
Maintain deployment documentation:DEPLOYMENT.md
Troubleshooting
Common Deployment Issues
“No valid credential sources found” Solution: Configure cloud provider credentials properly. “Resource already exists” Solution: Import existing resource into Terraform state:Learn More
Infrastructure Generation
Understand how Terraform is generated
Terraform Environment Management
Learn how to manage multiple environments with Terraform workspaces and variables
Terraform Configuration
Best practices for Terraform configuration
Local Development
How to develop applications locally with Suga