Documentation
¶
Overview ¶
Package tfgen generates a fully-formed OpenTofu working directory for the Gothic AWS stack. The base .tf.json files are embedded in the CLI binary and are NEVER seeded onto the user's project disk. They use OpenTofu's own "${var.*}" interpolation syntax (NOT Go text/template "{{...}}" markers) so they remain valid JSON consumable directly by OpenTofu. Per-deployment values are supplied at runtime via a generated vars.tf.json, and environment-variable sources (raw / SSM / Secrets Manager) are resolved via a generated env_resolved.tf.json. This mirrors the embed pattern used by pkg/helpers/wasm/wasm_templates.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TofuTemplateFS embed.FS
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct{}
Generator materialises an OpenTofu working directory for the AWS Gothic stack.
func (*Generator) Prepare ¶
func (g *Generator) Prepare(workDir string, params TfGenParams) error
Prepare writes a complete OpenTofu working directory into workDir:
- the embedded base .tf.json files (provider/backend, variables, resources, outputs)
- a generated vars.tf.json supplying concrete defaults for every variable
- a generated env_resolved.tf.json resolving env-var sources (raw/SSM/Secrets Manager)
- a gothic_outputs.tf.json placeholder
- a generated gothic_cache_policy.tf.json (the CloudFront server cache policy)
It NEVER writes to the user's project directory; only workDir is touched.
type TfGenParams ¶
type TfGenParams struct {
ProjectName string
Stage string
Suffix string
Region string
Profile string
ServerMemory int
ServerTimeout int
ECRImageURI string
BucketName string
LambdaName string
StateBucket string
LockTable string
EnvVars map[string]config.EnvValue
// The custom-domain fields are source-aware EnvValues (raw / SSM / Secrets
// Manager), resolved into locals by writeEnvResolved exactly like EnvVars. A nil
// pointer means the stage did not declare that field.
WafArn *config.EnvValue
CustomDomain *config.EnvValue
HostedZoneId *config.EnvValue
CertificateArn *config.EnvValue
// CDN drives the generated aws_cloudfront_cache_policy.server (which query params,
// cookies, and headers the dynamic/Lambda behavior folds into the cache key and
// forwards to the origin). Its zero value = all query params, no cookies, no
// headers. See writeCachePolicy.
CDN config.CDNConfig
// InfraDir is the user's custom-infrastructure directory (cwd-relative, like
// the "public/" asset dir). Every *.tf / *.tf.json file directly inside it is
// merged flat into workDir so the user's resources land in the SAME module +
// state as the Gothic stack, and can reference the stable local.gothic_*
// contract. Empty or absent → no-op. Non-.tf files are ignored.
InfraDir string
}
TfGenParams carries every concrete per-deployment value the generator needs to materialise vars.tf.json and env_resolved.tf.json. The base .tf.json files reference these via "${var.*}" / "${local.env_vars}".