AWS SAM CLI
$ sam Official Med RiskAWS SAM CLI (sam) builds, validates, locally invokes, and deploys serverless applications defined in SAM/CloudFormation templates, offering sam validate --lint, sam list --output json, and CloudFormation changeset previews via --no-execute-changeset.
brew install aws-sam-cli sam pairs local build/validate workflows with CloudFormation changeset previews directly in the project directory.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
sam list supports --output json and --no-confirm-changeset avoids prompts, though build/deploy emit mostly plain text logs.
sam list --output jsonand--no-confirm-changesetflags
sam validate --lint and sam deploy --no-execute-changeset provide reliable pre-flight safety checks.
- Supports
--no-execute-changesetchangeset preview
Available via Homebrew, PyPI, and official installers, though local container builds require Docker.
- Homebrew
aws-sam-cliand PyPI packages
Streamlines serverless packaging, local invoke, and deployment in one tool.
- Unified local test, build, and CloudFormation deploy
Official AWS repository (aws/aws-sam-cli) actively maintained under Apache-2.0.
- Official
aws/aws-sam-clirepository
Good command reference and --help, though many tutorials focus on --guided interactive usage.
- AWS SAM CLI Developer Guide
Security, Auth & Guardrails
Inherits AWS CLI credentials from ~/.aws/credentials, AWS_PROFILE, or AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY.
CLI is free (Apache-2.0); deployed Lambda/API Gateway resources incur AWS billing.
# AWS SAM CLI Agent Rules - Run `sam validate --lint` and `sam build` locally before any deploy command. - Never run `sam deploy --guided` (interactive); pass `samconfig.toml` or explicit flags + `--no-execute-changeset`. - Pin `--profile` and `--region` on all remote commands.
Agent-Ready Command Recipes
Safe Read-Only Queries
sam validate --lint
Validates CloudFormation/SAM syntax and cfn-lint rules without touching AWS.
sam list resources --stack-name my-app --output json
Queries deployed stack resources in structured JSON.
Controlled Writes & Previews
sam deploy --no-execute-changeset --no-confirm-changeset --resolve-s3
Stages a CloudFormation changeset for review without mutating live resources.
Strengths for Agents
- +
sam deploy --no-execute-changesetstages CloudFormation diffs safely. - +
sam validate --lintcatches template errors locally before upload. - + Reuses standard AWS CLI profiles and IAM boundaries.
Caveats & Pitfalls
- ! Avoid
sam deploy --guided, which requires interactive TTY input. - !
--output jsonis available onsam list/sam tracesbut notsam buildorsam deploy.