lmweblab reference

Complete reference for lmweblab lifecycle commands, CLI flags, environment variables, lmaws Web APIs, importable recipes, 12-scenario catalog entries, and exit codes.

Lifecycle commands and CLI flags

Command or flag Context Description
all web_stack.lms / scenarios Run up, test (plus phase2 and re-test if requested), and always run down even on failure
up web_stack.lms / scenarios Provision tagged stack resources and write private state under .lmweblab-local/
test web_stack.lms / scenarios Execute lmcurl HTTP contract assertions, XSS escaping checks, and p95 load latency checks
phase2 lmaws/web_stack.lms Attach validated ACM certificate, enable redirect-to-https on CloudFront, and wait Deployed
status web_stack.lms / scenarios Read masked state and live provider inventory without acquiring the lifecycle write lock
down web_stack.lms / scenarios Tear down all run-owned resources in reverse dependency order and verify zero leftovers
--offline All drivers Use deterministic synthetic transport and loopback fixtures at $0.00 cost (default)
--live All drivers Execute against real AWS in us-east-1 using AWS_PROFILE=lmaws and LMWEBLAB_DOMAIN
--phase2 / --acm web_stack.lms / scenario 01 Enable Phase 2 ACM DNS-validated certificate and HTTPS redirection
--run-id RUN_ID All drivers Specify an explicit lowercase hexadecimal run identifier instead of generating a fresh timestamp ID

Environment variables

Variable Default Description
LMWEBLAB_LIVE 0 Set to 1 (together with --live) to authorize live AWS provisioning
LMAWS_LIVE 0 Native lmaws live mutation gate; the drivers set it to 1 for live runs and 0 otherwise
AWS_PROFILE lmaws Required least-privilege AWS profile for live runs; administrator profiles are forbidden
AWS_REGION us-east-1 Target AWS region enforced by native lmaws and OpenTofu guards
LMWEBLAB_DOMAIN example.com Public Route 53 hosted-zone domain name used for site and application DNS records
LMWEBLAB_RUN_ID auto / cafe01 Run identifier used to scope resource names (lmaws-site-<run>) and lmaws_test=<run> tags
LMWEBLAB_WORKER_LIVE_GO 0 Additional confirmation flag (set to 1) required for live execution of Scenario 07 SQS worker

Native lmaws Web stack APIs

Method signature Description
Cloud.web_stack(run_id: string, domain: string, state_path: string) -> Web Open a persistent run-scoped web stack session storing raw provider IDs in state_path
Web.step(operation: string, json_args: string) -> Row Execute a guarded provisioning step (bucket, certificate, distribution, dns_site, compute, dns_app, https, invalidate)
Web.status() -> Rows Return masked resource status and phase timings for the current run
Web.leftovers() -> Rows Query live AWS provider state for any remaining resources belonging to this run
Web.down() -> Row Tear down all owned stack resources in reverse order and assert zero remaining leftovers
Cloud.web_find(run_id: string, domain: string) -> Rows Independent read-only account inventory across S3, CloudFront, ACM, Route 53, and EC2 for run_id
settle(seconds) on a cloud.serverless_stack session Wait and sweep delayed CloudWatch log groups after Lambda teardown before final leftover audit

Importable step recipes (lmaws/recipes/steps.lms)

Function signature Description
web_bucket(opts: map, site_dir: string) -> map Create private tagged S3 bucket with Block Public Access and upload the five static site assets
web_certificate(opts: map) -> map Request ACM certificate in us-east-1, create Route 53 DNS validation CNAME, and wait for issuance
web_distribution(opts: map) -> map Create tagged CloudFront distribution and SigV4 OAC (attaching prepared certificate if present) and wait Deployed
web_site_dns(opts: map) -> map Create Route 53 alias A record pointing to the CloudFront distribution and wait INSYNC
web_compute(opts: map, settings: map) -> map Launch tagged Spot t4g.nano/t3.nano instance with 8 GiB gp3 disk, caller /32 security group, and Python user-data server
web_app_dns(opts: map) -> map Create Route 53 A record (TTL 60) for the Spot instance public IPv4 and wait INSYNC
web_https(opts: map) -> map Update CloudFront viewer protocol policy to redirect-to-https and wait Deployed
web_invalidate(opts: map) -> map Create a CloudFront cache invalidation restricted strictly to the current run distribution

Scenario catalog (scenarios/01..12)

Scenario directory AWS services Verified contract
01-static-site-s3-cloudfront S3, CloudFront OAC, Route 53, ACM 200 OK static assets, gzip CSS, custom 404, optional ACM TLS and 301 HTTPS redirect, 0 leftovers
02-dynamic-page-spot-nano EC2 Spot nano, Security Group (/32), Route 53, SSM HTML-escaped ?echo= XSS check, monotonic /api/info counter and timestamps, p95 load check, 0 leftovers
03-lambda-function-url-hello Lambda (python3.12), Function URL, CloudFront, Route 53, CloudWatch Logs JSON schema check, cold vs warm latency, CloudFront alias delivery, 4-VU load p95, 0 leftovers
04-lambda-dynamodb-guestbook Lambda Function URL, DynamoDB (PAY_PER_REQUEST, TTL), CloudWatch Logs POST/GET guestbook entries, HTML escaping, cursor pagination, TTL attribute check, 0 leftovers
05-static-plus-api S3 (OAC), CloudFront (multi-origin / and /api/*), Lambda Function URL, Route 53 Same-origin cached static HTML and uncached /api/* JSON without CORS, 4-VU load p95, 0 leftovers
06-scheduled-report EventBridge (rate(1 minute)), Lambda, S3, DynamoDB, CloudWatch Logs Manual and scheduled EventBridge executions persisted in S3 and DynamoDB, HTML report fetch, 0 leftovers
07-sqs-worker Lambda, SQS queue, SQS DLQ, DynamoDB Async job completion via SQS worker and poison message routing to DLQ, list-verified mapping cleanup, 0 leftovers
08-session-login-demo Lambda Function URL, DynamoDB (TTL) Login cookie issuance, authenticated session read, logout invalidation, and expiry, 0 leftovers
09-url-shortener Lambda Function URL, DynamoDB Short-code registration, 301/302 redirect, 404 on unknown code, atomic hit counter increment, 0 leftovers
10-presigned-upload-gallery Lambda Function URL, S3, CloudFront Presigned S3 PUT upload, CloudFront gallery fetch, content-type and byte-size enforcement, 0 leftovers
11-weighted-dns-two-backends Route 53 weighted A records, S3, CloudFront OAC, EC2 Spot nano 90/10 -> 50/50 -> 0/100 traffic split verified via DoH ECS /24 sampling within 3-sigma binomial bands, 0 leftovers
12-maintenance-page-failover Route 53, S3, CloudFront, EC2 Spot nano Live DNS cutover from dynamic application to static maintenance page and restoration, 0 leftovers

Exit codes

Exit code Component Meaning
0 Drivers and hosts All lifecycle steps, HTTP assertions, teardown operations, and zero-leftover checks passed
1 lmscript driver Lifecycle step or HTTP contract assertion failed (the all driver attempts down.lms before exiting 1)
2 lmcode hosts Invalid CLI syntax or contradictory invocation metadata
3 lmcode hosts Bytecode load failure, safety/ownership/cost-cap refusal, AWS provider error, or HTTP contract failure
4 lmcode hosts Application-level failure tagged APP_FAIL