SAM Deploy
Deploys the SAM application to AWS. Runs build, validation, and deploy steps in sequence.
Steps
Validate the template
sam validate --lintFix any validation errors before proceeding.
Build the application
sam buildIf the build fails due to Python version mismatch, retry with:
sam build --use-containerCheck for YAML issues Verify no duplicate keys were introduced by automated edits:
python3 -c "import yaml; yaml.safe_load(open('template.yaml'))"Deploy For standard (non-production) deploys:
sam deployThis uses settings from
samconfig.toml. Ensureconfirm_changeset = falsefor automated deploys.For first-time or guided deploys:
sam deploy --guidedVerify deployment Check the CloudFormation stack status:
aws cloudformation describe-stacks --stack-name <STACK_NAME> --query 'Stacks[0].StackStatus'
Troubleshooting
- First deploy KMS/CreateGrant failure: Delete the failed stack with
sam deleteand redeploy. - Multiple GSI changes: CloudFormation only supports adding/removing one GSI per update. Delete and redeploy if multiple GSI changes are needed.
- Build errors: Check that the Python version on PATH matches the runtime specified in
template.yaml.
Post-Deploy
- Run seed scripts if this is a fresh deployment:
bash scripts/seed.sh(if present). - Check CloudWatch Logs for any startup errors in the deployed functions.
Source: aws-samples/serverless-samples — distributed by TomeVault.