Documentation
¶
Overview ¶
Package forge is the Go replacement for SST (Serverless Stack). Import this in your infra/sst.config.go and call forge.Run() from main(). The forge CLI sets FORGE_MODE to control deploy/dev/remove behaviour.
Index ¶
- Constants
- func Run(cfg *Config)
- type AppConfig
- type CloudflareConfig
- type Config
- type DevHandler
- type DevOutputFile
- type Linkable
- type RemovalPolicy
- type RunContext
- func (r *RunContext) DevQueues() (reqURL, resURL pulumi.StringOutput, ok bool)
- func (r *RunContext) Export(name string, value interface{})
- func (r *RunContext) ExtraTags() map[string]string
- func (r *RunContext) IsProduction() bool
- func (r *RunContext) Pulumi() *pulumi.Context
- func (r *RunContext) SetDevQueues(reqURL, resURL pulumi.StringOutput)
- func (r *RunContext) StageIn(stages ...string) bool
- type StageConfig
Constants ¶
const PulumiVersion = "3.247.0"
PulumiVersion is the Pulumi CLI version bundled and managed by forge. Update this alongside the pulumi/sdk/v3 dependency in go.mod.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppConfig ¶
type AppConfig struct {
Name string
Home string // "aws" | "cloudflare" | "aws+cloudflare"
Removal RemovalPolicy // default: RemovalDestroy
Cloudflare *CloudflareConfig
}
AppConfig holds project-level metadata.
type CloudflareConfig ¶
type CloudflareConfig struct {
// AccountID is the Cloudflare account ID. Defaults to CLOUDFLARE_ACCOUNT_ID.
AccountID string
// ZoneID is the Cloudflare zone ID used for custom Worker domains. Defaults to CLOUDFLARE_ZONE_ID.
ZoneID string
}
CloudflareConfig holds Cloudflare account settings used by CF constructs. Fields default to the corresponding CLOUDFLARE_* environment variables.
type Config ¶
type Config struct {
App *AppConfig
Stages map[string]*StageConfig // per-stage overrides; key is the stage name
Run func(ctx *RunContext) error
}
Config is the top-level definition of your infrastructure. Create one in infra/sst.config.go and pass it to forge.Run().
type DevHandler ¶ added in v0.3.3
DevHandler holds the resolved ARN and local source path for one function.
type DevOutputFile ¶ added in v0.3.3
type DevOutputFile struct {
RequestQueueURL string `json:"requestQueueUrl"`
ResponseQueueURL string `json:"responseQueueUrl"`
Handlers map[string]DevHandler `json:"handlers"`
}
DevOutputFile is the JSON structure written to FORGE_DEV_OUTPUT_FILE after a successful dev-mode deploy. The CLI reads it to start the local tunnel.
type Linkable ¶
Linkable is implemented by any construct that can be linked to a Function (injecting its ARNs / URLs as environment variables at deploy time). Only constructs provided by this module are intended to implement this interface.
type RemovalPolicy ¶
type RemovalPolicy string
RemovalPolicy controls what happens to resources when a stage is torn down.
const ( RemovalDestroy RemovalPolicy = "destroy" RemovalRetain RemovalPolicy = "retain" RemovalRetainOnProtection RemovalPolicy = "retain-on-protection" )
type RunContext ¶
type RunContext struct {
Stage string
App *AppConfig
AccountID string // AWS account ID — used to ensure globally unique resource names
WorkDir string // absolute path to the infra/ directory at deploy time
DevMode bool
IsProtected bool
// contains filtered or unexported fields
}
RunContext is passed to your Config.Run function. Use it to create constructs and export stack outputs.
func NewRunContext ¶ added in v0.3.2
func NewRunContext(pctx *pulumi.Context, app *AppConfig, stage, accountID string) *RunContext
NewRunContext constructs a RunContext suitable for testing infrastructure programs. Pass the *pulumi.Context received inside a pulumi.RunErr callback that uses pulumi.WithMocks.
err := pulumi.RunErr(func(pctx *pulumi.Context) error {
ctx := forge.NewRunContext(pctx, &forge.AppConfig{Name: "myapp"}, "test", "123456789012")
// create constructs and assert on them
return nil
}, pulumi.WithMocks("myapp", "test", mocks))
func (*RunContext) DevQueues ¶ added in v0.3.3
func (r *RunContext) DevQueues() (reqURL, resURL pulumi.StringOutput, ok bool)
DevQueues returns the shared SQS queue URLs set by the first dev-mode NewFunction.
func (*RunContext) Export ¶
func (r *RunContext) Export(name string, value interface{})
Export exposes a stack output visible in `forge deploy` output and the SST Console. value must be a pulumi.Output or a plain string/int.
func (*RunContext) ExtraTags ¶
func (r *RunContext) ExtraTags() map[string]string
ExtraTags returns the additional resource tags configured for this stage via StageConfig.Tags.
func (*RunContext) IsProduction ¶
func (r *RunContext) IsProduction() bool
IsProduction returns true when the active stage is "production" or "prod".
func (*RunContext) Pulumi ¶
func (r *RunContext) Pulumi() *pulumi.Context
Pulumi returns the underlying pulumi.Context for advanced use cases.
func (*RunContext) SetDevQueues ¶ added in v0.3.3
func (r *RunContext) SetDevQueues(reqURL, resURL pulumi.StringOutput)
SetDevQueues stores the shared SQS queue URLs for the dev tunnel and exports them as stack outputs. Called by constructs.NewFunction on the first dev-mode function. Subsequent calls are no-ops.
func (*RunContext) StageIn ¶
func (r *RunContext) StageIn(stages ...string) bool
StageIn returns true if the active stage matches any of the provided names.
type StageConfig ¶
type StageConfig struct {
// Removal overrides the base AppConfig removal policy for this stage.
Removal RemovalPolicy
// AWSProfile uses a different AWS credentials profile when deploying this stage.
AWSProfile string
// AWSRegion deploys this stage to a different AWS region.
AWSRegion string
// Protected means `forge remove` requires --force to proceed.
Protected bool
// Tags adds extra resource tags for every resource in this stage.
Tags map[string]string
}
StageConfig holds per-stage overrides applied on top of the base AppConfig.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
forge
command
Package main is the forge CLI — a drop-in replacement for the sst CLI.
|
Package main is the forge CLI — a drop-in replacement for the sst CLI. |
|
forge-stub
command
forge-stub is the thin proxy Lambda binary deployed by `forge dev`.
|
forge-stub is the thin proxy Lambda binary deployed by `forge dev`. |
|
cloudflare
Package cloudflare provides Pulumi constructs for Cloudflare resources (Workers, KV, D1, R2).
|
Package cloudflare provides Pulumi constructs for Cloudflare resources (Workers, KV, D1, R2). |
|
Package dev implements the live Lambda development tunnel.
|
Package dev implements the live Lambda development tunnel. |
|
Example infra/sst.config.go This is what a typical forge project looks like.
|
Example infra/sst.config.go This is what a typical forge project looks like. |
|
internal
|
|
|
bootstrap
Package bootstrap creates and validates the S3 bucket used for Pulumi state storage.
|
Package bootstrap creates and validates the S3 bucket used for Pulumi state storage. |
|
pulumibundle
Package pulumibundle ensures the Pulumi CLI binary is available, downloading it automatically when it is not found on PATH.
|
Package pulumibundle ensures the Pulumi CLI binary is available, downloading it automatically when it is not found on PATH. |
|
templates
Package templates embeds the forge project template files.
|
Package templates embeds the forge project template files. |
|
Package migrate converts an existing sst.config.ts to sst.config.go.
|
Package migrate converts an existing sst.config.ts to sst.config.go. |
|
Package secrets provides SSM Parameter Store backed secrets management, equivalent to SST's `sst secret` commands.
|
Package secrets provides SSM Parameter Store backed secrets management, equivalent to SST's `sst secret` commands. |