-
-
Notifications
You must be signed in to change notification settings - Fork 5
docs: add core concepts, resources, support and more #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1c9624a
docs: add more docs on foundations, resources, support and more
jyecusch 9d8c550
chore: move 'foundations' to 'core concepts'
jyecusch 2e53e55
chore: improve diagram text contrast
jyecusch ba13f51
chore: fix escaped quotes on storage prefix param python
HomelessDinosaur c555f3f
chore: edits from code review
jyecusch 7f8ed2d
docs: merge env mgmt into tf config page
jyecusch f61219d
docs: improvements from review feedback
jyecusch 363df33
docs: fix python examples
jyecusch a60bf8c
docs: edits from feedback
jyecusch e9683a2
docs: add note about local schedules
jyecusch a5f05cb
docs: add missing subtypes in example config
jyecusch 4bf417d
docs: add relevant links to cloud deployment pages
jyecusch 4603244
docs: add missing subtypes in config example
jyecusch 39c76f0
docs: add more subtype notes to config examples
jyecusch 090de69
chore: spelling and links
jyecusch b1eef97
docs: update overview doc sidebar titles
jyecusch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| --- | ||
| title: "Infrastructure Generation" | ||
| description: "How Suga transforms projects into production-ready Terraform" | ||
| --- | ||
|
|
||
| When you run `suga build`, Suga transforms your high-level project specification into production-ready Terraform code. This page explains how this transformation works, what gets generated, and how to customize the output. | ||
|
|
||
| ## The Build Process | ||
|
|
||
| The `suga build` command orchestrates a multi-step process: | ||
|
|
||
| <Steps> | ||
| <Step title="Load Project"> | ||
| Suga reads your `suga.yaml` file and validates the configuration: | ||
|
|
||
| ```yaml title="suga.yaml" | ||
| target: suga/aws@1 | ||
| name: my-app | ||
|
|
||
| services: | ||
| api: | ||
| subtype: lambda | ||
| dev: | ||
| script: npm run dev | ||
|
|
||
| buckets: | ||
| subtype: s3 | ||
| uploads: | ||
| access: | ||
| api: [read, write] | ||
| ``` | ||
| </Step> | ||
|
|
||
| <Step title="Fetch Platform"> | ||
| Suga retrieves the target platform specification from the registry: | ||
|
|
||
| ```bash | ||
| # Platform: suga/aws@1 | ||
| - Services: lambda, fargate | ||
| - Buckets: s3 | ||
| - Databases: neon | ||
| - Entrypoints: cloudfront | ||
| - Infrastructure: vpc, loadbalancer, security-groups | ||
| ``` | ||
| </Step> | ||
|
|
||
| <Step title="Map Resources"> | ||
| Each project resource is mapped to a platform blueprint, by the selected subtype: | ||
|
|
||
| ```yaml suga.yaml | ||
| services: | ||
| api: | ||
| subtype: fargate | ||
|
|
||
| buckets: | ||
| uploads: | ||
| subtype: s3 | ||
| ``` | ||
|
|
||
| ``` | ||
| Project Platform Blueprint Plugin | ||
| ------- ------------------ ------ | ||
| service "api" → services.fargate → suga/aws/fargate | ||
| bucket "uploads" → buckets.s3 → suga/aws/s3-bucket | ||
| ``` | ||
|
|
||
| </Step> | ||
|
|
||
| <Step title="Generate Terraform Output"> | ||
| Suga then uses Terraform CDK to resolve the modules, variables and other configuration to produce a Terraform stack. | ||
|
|
||
| ``` | ||
| terraform/stacks/my-app/ | ||
| ├── cdk.tf.json # Main Terraform Entrypoint | ||
| └── .terraform/ # Plugin Terraform modules | ||
| └── modules/ | ||
| ├── api/ | ||
| ├── api_image/ | ||
| ├── uploads_bucket/ | ||
| └── ... | ||
| ``` | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| ## Module Naming | ||
|
|
||
| Suga generates consistent module names for application resources: | ||
|
|
||
| ### Terraform Module Names | ||
|
|
||
| Pattern: `{resource_name}_{submodule_name}` | ||
|
|
||
| ```hcl | ||
| module "api" # Service named "api" | ||
| module "api_image" # Container image submodule for the "api" service | ||
| module "uploads" # Bucket named "uploads" | ||
| ``` | ||
|
|
||
| ## Dependency Management | ||
|
|
||
| Suga automatically manages resource dependencies: | ||
|
|
||
| ### Explicit Dependencies | ||
|
|
||
| Defined by platform: | ||
|
|
||
| ```yaml title="Platform blueprint" | ||
| services: | ||
| fargate: | ||
| depends_on: | ||
| - ${infra.aws_vpc} | ||
| - ${infra.aws_lb} | ||
| ``` | ||
|
|
||
| Results in: | ||
|
|
||
| ```hcl title="Generated Terraform" | ||
| module "service_api" { | ||
| # ... | ||
| depends_on = [ | ||
| module.aws_vpc, | ||
| module.aws_lb | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Implicit Dependencies | ||
|
|
||
| Created by resource references: | ||
|
|
||
| ```hcl title="Automatic dependency" | ||
| module "service_api" { | ||
| vpc_id = module.aws_vpc.vpc_id # Creates implicit dependency | ||
| } | ||
| ``` | ||
|
|
||
| ## Multi-Environment Support | ||
|
|
||
| The same generated Terraform can deploy to multiple environments using Terraform workspaces and environment-specific variable files. This allows you to maintain a single infrastructure definition while customizing configuration for dev, staging, and production. | ||
|
|
||
| <Card title="Terraform Environment Management" icon="layers" href="/deploy/terraform-configuration#environment-management" horizontal> | ||
| Learn how to manage multiple environments with Terraform workspaces and variables | ||
| </Card> | ||
|
|
||
| See the [CLI reference](/cli/build) for complete build options. | ||
|
|
||
| ## Getting Help | ||
|
|
||
| If you encounter issues during build: | ||
|
|
||
| 1. Review platform documentation in the [platform browser](https://app.addsuga.com/browse/platforms) | ||
| 2. Contact [Suga support](/support) | ||
|
|
||
| ## Best Practices | ||
|
|
||
| ### 1. Version Control Generated Terraform | ||
|
|
||
| Commit generated Terraform to version control: | ||
|
|
||
| ```bash | ||
| git add terraform/ | ||
| git commit -m "Update infrastructure" | ||
| ``` | ||
|
|
||
| Benefits: | ||
| - Track infrastructure changes over time | ||
| - Review Terraform diffs in pull requests | ||
| - Rollback if needed | ||
|
|
||
| ### 2. Validate Before Deploying | ||
|
|
||
| Always validate and preview: | ||
|
|
||
| ```bash | ||
| suga build | ||
| cd terraform/stacks/my-app | ||
| terraform init | ||
| terraform validate | ||
| terraform plan # Review before apply | ||
| ``` | ||
|
|
||
| ## Learn More | ||
|
|
||
| <CardGroup cols={2}> | ||
| <Card title="Deployment Guide" icon="rocket" href="/deploy/overview"> | ||
| Understand the deployment process | ||
| </Card> | ||
|
|
||
| <Card title="Build Command" icon="hammer" href="/cli/build"> | ||
| Complete CLI reference for `suga build` | ||
| </Card> | ||
|
|
||
| <Card title="Platform Development" icon="layers" href="/guides/build-platform"> | ||
| Learn how platforms define infrastructure | ||
| </Card> | ||
|
|
||
| <Card title="Terraform Configuration" icon="code" href="/deploy/terraform-configuration"> | ||
| Best practices for Terraform configuration | ||
| </Card> | ||
| </CardGroup> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.