# AWS Serverless Application Model (AWS SAM)

Cloud service · AWS. Updated 2026-11-12. Page: https://blowstack.com/tools/cloud-services-hub/aws-serverless-application-model-(aws-sam)

> AWS Serverless Application Model (AWS SAM) is a framework for building serverless applications that simplifies the process of defining, deploying, and managing serverless infrastructure on AWS using familiar infrastructure as code techniques.

Practice exams covering AWS Serverless Application Model (AWS SAM): [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional).

## 10 key features of AWS Serverless Application Model (AWS SAM)

AWS SAM streamlines serverless application development by offering infrastructure as code, seamless AWS integration, local testing, simple deployment, and built-in best practices.

1. **Infrastructure as Code**: AWS SAM allows you to define your serverless applications and their resources using simple YAML configuration. This enables version-controlled, repeatable, and automated setups.
2. **Seamless Integration with AWS Services**: It integrates tightly with AWS services such as Lambda, DynamoDB, and API Gateway, making it easier to compose complex applications with these managed services.
3. **Local Testing and Debugging**: AWS SAM provides tools for local testing and debugging of serverless applications, making development faster and more efficient.
4. **Simple Deployment**: SAM simplifies the deployment process of your serverless applications by using CloudFormation under the hood, allowing you to deploy with a single command.
5. **Built-in Best Practices**: AWS SAM includes a number of built-in best practices for security, reliability, and efficiency, helping developers follow AWS best practices with less effort.
6. **AWS SAM Connectors**: AWS SAM connectors define permissions between AWS resources in SAM templates. SAM transforms these definitions into the IAM permissions needed for the specified interactions.
7. **Continuous Cloud Sync**: The SAM CLI's sam sync command automatically synchronizes local changes to the cloud to accelerate development and cloud testing.
8. **Terraform Application Testing**: The AWS SAM CLI supports local debugging and testing of Lambda functions and layers in Terraform serverless applications.
9. **Container-based Builds**: SAM can build functions inside Lambda-compatible containers using --use-container, ensuring dependencies use the correct architecture and glibc versions for the Lambda runtime environment.
10. **CI/CD Pipeline Support**: The AWS SAM CLI includes features for creating continuous integration and continuous delivery (CI/CD) pipelines for serverless applications.

## Where AWS Serverless Application Model (AWS SAM) is used

AWS Serverless Application Model (SAM) enables easy deployment and management of serverless applications for use cases such as building API backends, automating business processes, developing chatbots, processing data in real-time, and executing scheduled tasks.

1. **Building API Backends**: AWS SAM allows developers to easily build serverless API backends that automatically scale up and down based on demand. With SAM, you can define APIs directly in your template and connect them with Lambda functions to process HTTP requests. This makes it straightforward to create and deploy RESTful APIs without managing servers.
2. **Automating Business Processes**: AWS SAM facilitates the automation of business processes by allowing developers to integrate various AWS services. By defining event-driven Lambda functions, businesses can automate workflows, such as order processing, file conversions, or data validations, without provisioning or managing servers, thus reducing operational complexity and cost.
3. **Developing Chatbots**: With AWS SAM, developers can easily deploy and manage serverless infrastructure for chatbots. By leveraging Amazon Lex for conversational interfaces and connecting it with Lambda for processing logic, SAM streamlines the deployment of chatbots across various platforms, allowing businesses to engage with customers efficiently.
4. **Real-time Data Processing**: AWS SAM is ideal for setting up serverless architectures capable of processing data streams in real-time. Whether it's processing logs, social media feeds, or real-time analytics, SAM, in conjunction with AWS Lambda and Amazon Kinesis, enables scalable, on-the-fly data processing without the need to manage underlying infrastructure.
5. **Scheduled Tasks**: AWS SAM simplifies the execution of scheduled tasks using AWS Lambda functions. This is particularly useful for tasks such as database cleanups, inventory updates, or periodic data processing. By defining the schedule in the SAM template, tasks can be automated without the overhead of server maintenance.

## How AWS Serverless Application Model (AWS SAM) is priced

AWS SAM follows a Pay-As-You-Go model with added benefits of a free tier that includes 1 million free requests per month and 400,000 GB-seconds of compute time for AWS Lambda.

- **No Additional Charge**: AWS SAM is available at no additional charge; you pay for the AWS resources your application uses under each service's pricing. Pricing is based on the actual amount of resources that your application consumes, which could include Lambda executions, API Gateway calls, and DynamoDB read/write operations.

## Services AWS Serverless Application Model (AWS SAM) works with

- **[Amazon API Gateway](https://blowstack.com/tools/cloud-services-hub/amazon-api-gateway)**: AWS SAM defines REST APIs and HTTP APIs, connects their routes to Lambda functions, and configures features such as authorization and custom domains. Its local API emulation lets you test requests before deployment.
- **[Amazon Athena](https://blowstack.com/tools/cloud-services-hub/amazon-athena)**: AWS SAM provides an Athena query policy template that grants a function permissions to run and inspect queries, with access to the specified query-results bucket.
- **[Amazon CloudWatch](https://blowstack.com/tools/cloud-services-hub/amazon-cloudwatch)**: AWS SAM configures CloudWatch Logs and scheduled or rule-based function triggers, and its policy templates grant permissions for publishing metrics and managing dashboards. The sam logs command retrieves logs from deployed applications.
- **[Amazon Cognito](https://blowstack.com/tools/cloud-services-hub/amazon-cognito)**: AWS SAM configures Cognito user pools as API authorizers and connects Lambda functions to user-pool triggers. It also provides a policy template for reading user-pool information.
- **[Amazon Comprehend](https://blowstack.com/tools/cloud-services-hub/amazon-comprehend)**: AWS SAM provides a Comprehend policy template that grants a function permissions for text-analysis operations, such as detecting sentiment or entities.
- **[Amazon Data Firehose](https://blowstack.com/tools/cloud-services-hub/amazon-kinesis-data-firehose)**: AWS SAM provides policy templates for writing records to a specified Firehose delivery stream or managing delivery streams.
- **[Amazon DynamoDB](https://blowstack.com/tools/cloud-services-hub/amazon-dynamodb)**: AWS SAM provisions DynamoDB tables through its SimpleTable resource and configures DynamoDB Streams to invoke Lambda functions. Connectors and policy templates generate permissions for table access, stream consumption, and backup operations.
- **[Amazon EC2](https://blowstack.com/tools/cloud-services-hub/amazon-ec2)**: AWS SAM includes policy templates that grant functions permissions to describe EC2 resources and AMIs or copy machine images. These support serverless automation that inventories instances or manages images.
- **[Amazon Elastic Container Registry (Amazon ECR)](https://blowstack.com/tools/cloud-services-hub/amazon-elastic-container-registry-(amazon-ecr))**: AWS SAM builds and pushes container-image Lambda applications to ECR repositories during packaging and deployment. It can resolve or create repositories for image-based functions.
- **[Amazon Elastic File System (Amazon EFS)](https://blowstack.com/tools/cloud-services-hub/amazon-elastic-file-system-(amazon-efs))**: AWS SAM configures EFS access-point mounts for Lambda functions through their file-system settings. Its EFS policy template grants the permissions needed to mount and access the file system.
- **[Amazon Elastic Kubernetes Service (Amazon EKS)](https://blowstack.com/tools/cloud-services-hub/amazon-elastic-kubernetes-service-(amazon-eks))**: AWS SAM provides an EKS describe policy template that grants a function permission to retrieve information about a specified cluster.
- **[Amazon EMR](https://blowstack.com/tools/cloud-services-hub/amazon-emr)**: AWS SAM provides a policy template that grants a function permission to add job-flow steps to an EMR cluster, supporting serverless submission of processing jobs.
- **[Amazon EventBridge](https://blowstack.com/tools/cloud-services-hub/amazon-eventbridge)**: AWS SAM defines EventBridge rules and schedules that invoke Lambda functions or start Step Functions workflows. It also provides a policy template for publishing events to an event bus.
- **[Amazon Kinesis Data Streams](https://blowstack.com/tools/cloud-services-hub/amazon-kinesis-data-streams)**: AWS SAM configures Kinesis event-source mappings that invoke Lambda functions with stream records. Its policy templates grant read, write, or management access to specified streams.
- **[Amazon Lex](https://blowstack.com/tools/cloud-services-hub/amazon-lex)**: AWS SAM provides a Lex policy template that grants a function permissions to interact with bots, including sending text or audio input.
- **[Amazon Managed Streaming for Apache Kafka](https://blowstack.com/tools/cloud-services-hub/amazon-managed-streaming-for-apache-kafka)**: AWS SAM configures Amazon MSK event sources for Lambda functions, including topics and consumer settings. Its policy templates provide permissions for reading cluster information and accessing encrypted clusters.
- **[Amazon MQ](https://blowstack.com/tools/cloud-services-hub/amazon-mq)**: AWS SAM defines Amazon MQ event-source mappings so broker messages invoke Lambda functions. Its broker-access policy template supplies permissions needed to discover the broker and access associated credentials.
- **[Amazon OpenSearch Service](https://blowstack.com/tools/cloud-services-hub/amazon-opensearch-service)**: AWS SAM includes policy templates for granting functions HTTP-operation permissions on OpenSearch Service domains, such as reading indexed documents or writing search data.
- **[Amazon Polly](https://blowstack.com/tools/cloud-services-hub/amazon-polly)**: AWS SAM provides a Polly policy template that grants a function access to speech-synthesis operations.
- **[Amazon Rekognition](https://blowstack.com/tools/cloud-services-hub/amazon-rekognition)**: AWS SAM provides Rekognition policy templates for detection, label analysis, and face-collection operations. These let an application grant its functions permissions appropriate to their image-analysis tasks.
- **[Amazon Route 53](https://blowstack.com/tools/cloud-services-hub/amazon-route-53)**: AWS SAM can create Route 53 DNS records for API Gateway custom domains through its domain configuration. It also provides a policy template for functions that update records in a specified hosted zone.
- **[Amazon S3](https://blowstack.com/tools/cloud-services-hub/amazon-s3)**: AWS SAM uploads deployment artifacts to S3 and configures bucket notifications that invoke Lambda functions. Its connectors and policy templates generate permissions for reading and writing application objects.
- **[Amazon SageMaker](https://blowstack.com/tools/cloud-services-hub/amazon-sagemaker)**: AWS SAM provides policy templates for invoking SageMaker endpoints and performing selected endpoint-management operations. For example, a function can receive permission to invoke a specified inference endpoint.
- **[Amazon Simple Email Service (Amazon SES)](https://blowstack.com/tools/cloud-services-hub/amazon-simple-email-service-(amazon-ses))**: AWS SAM provides SES policy templates for sending email and working with email templates, including bulk templated messages.
- **[Amazon Simple Notification Service (Amazon SNS)](https://blowstack.com/tools/cloud-services-hub/amazon-simple-notification-service-(amazon-sns))**: AWS SAM configures SNS subscriptions that invoke Lambda functions and generates the necessary invocation permissions. Its connectors and policy templates can also grant functions permission to publish to topics.
- **[Amazon Simple Queue Service (Amazon SQS)](https://blowstack.com/tools/cloud-services-hub/amazon-simple-queue-service-(amazon-sqs))**: AWS SAM configures SQS queues as Lambda event sources, including batch handling and scaling settings. Connectors and policy templates generate permissions for consuming or sending messages.
- **[Amazon Textract](https://blowstack.com/tools/cloud-services-hub/amazon-textract)**: AWS SAM provides a Textract policy template that grants functions permissions to detect document text and analyze document structure.
- **[Amazon VPC](https://blowstack.com/tools/cloud-services-hub/amazon-vpc)**: AWS SAM configures Lambda functions with VPC subnet and security-group settings. Its VPC-access policy template supplies the network-interface permissions needed for those functions to access private resources.
- **[AWS AppSync](https://blowstack.com/tools/cloud-services-hub/aws-appsync)**: AWS SAM provides a GraphQLApi resource for defining AppSync GraphQL APIs, including schemas, authorization, data sources, functions, and resolvers.
- **[AWS Certificate Manager (ACM)](https://blowstack.com/tools/cloud-services-hub/aws-certificate-manager-(acm))**: AWS SAM's API custom-domain configuration accepts ACM certificate ARNs to configure HTTPS domains for API Gateway APIs.
- **[AWS Cloud9](https://blowstack.com/tools/cloud-services-hub/aws-cloud9)**: AWS Cloud9's AWS Toolkit uses AWS SAM to build, locally run, debug, and deploy serverless applications from the development environment.
- **[AWS CloudFormation](https://blowstack.com/tools/cloud-services-hub/aws-cloudformation)**: AWS SAM extends CloudFormation with a transform that expands concise serverless definitions into CloudFormation resources. CloudFormation then creates, updates, and deletes the application's stacks, and standard CloudFormation resources can coexist with SAM resources.
- **[AWS CodeBuild](https://blowstack.com/tools/cloud-services-hub/aws-codebuild)**: AWS SAM's pipeline templates use CodeBuild to build, test, and package serverless applications. SAM build-container images provide build environments suitable for these automated jobs.
- **[AWS CodeCommit](https://blowstack.com/tools/cloud-services-hub/aws-codecommit)**: AWS SAM can generate deployment pipelines that use a CodeCommit repository as their source. It also provides policy templates for functions that read or manage repository contents.
- **[AWS CodeDeploy](https://blowstack.com/tools/cloud-services-hub/aws-codedeploy)**: AWS SAM uses CodeDeploy for gradual Lambda deployments configured through DeploymentPreference. It generates deployment resources for canary or linear traffic shifting, with optional validation hooks and alarm-based rollback.
- **[AWS CodePipeline](https://blowstack.com/tools/cloud-services-hub/aws-codepipeline)**: AWS SAM can generate CodePipeline-based CI/CD pipelines that build and deploy serverless applications through successive environments. It also provides a policy template for Lambda functions that report pipeline job success or failure.
- **[AWS Identity and Access Management (IAM)](https://blowstack.com/tools/cloud-services-hub/aws-identity-and-access-management-(iam))**: AWS SAM creates execution roles and generates IAM policies from policy templates and connectors. This lets applications declare permissions between supported resources without hand-writing every policy statement.
- **[AWS IoT Core](https://blowstack.com/tools/cloud-services-hub/aws-iot-core)**: AWS SAM supports IoT rule events that create AWS IoT Core topic rules and connect matching MQTT messages to Lambda functions.
- **[AWS Key Management Service (AWS KMS)](https://blowstack.com/tools/cloud-services-hub/aws-key-management-service-(aws-kms))**: AWS SAM configures KMS keys for supported Lambda encryption settings and provides policy templates for encrypting and decrypting application data with specified keys.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: AWS SAM defines Lambda functions, layers, event sources, execution permissions, aliases, and deployment settings. Its development tools build function packages or images, invoke functions locally, and synchronize code changes to deployed functions.
- **[AWS Organizations](https://blowstack.com/tools/cloud-services-hub/aws-organizations)**: AWS SAM provides an Organizations policy template that grants a function permission to list accounts, supporting serverless account-inventory automation.
- **[AWS Resource Groups and Tag Editor](https://blowstack.com/tools/cloud-services-hub/aws-resource-groups-and-tag-editor)**: AWS SAM application templates can include a stack-based Resource Group used to group the application's resources for CloudWatch Application Insights monitoring.
- **[AWS Secrets Manager](https://blowstack.com/tools/cloud-services-hub/aws-secrets-manager)**: AWS SAM provides a policy template that grants a function permission to retrieve a specified secret. Its supported broker event-source settings can also reference Secrets Manager credentials for connecting Lambda consumers.
- **[AWS Serverless Application Repository](https://blowstack.com/tools/cloud-services-hub/aws-serverless-application-repository)**: AWS SAM publishes packaged applications to the Serverless Application Repository and deploys repository applications as nested applications through its Application resource.
- **[AWS Signer](https://blowstack.com/tools/cloud-services-hub/aws-signer)**: AWS SAM can sign Lambda deployment packages and layers during packaging or deployment using specified AWS Signer profiles. Function definitions can reference a Lambda code-signing configuration to enforce signature requirements.
- **[AWS Step Functions](https://blowstack.com/tools/cloud-services-hub/aws-step-functions)**: AWS SAM defines Step Functions state machines, execution roles, and event triggers through its StateMachine resource. Connectors and policy templates generate permissions for workflows to invoke resources and for functions to start executions.
- **[AWS Systems Manager](https://blowstack.com/tools/cloud-services-hub/aws-systems-manager)**: AWS SAM provides policy templates that grant functions read access to specified Systems Manager Parameter Store parameters. Templates can also resolve Parameter Store values through CloudFormation-supported references.
- **[AWS X-Ray](https://blowstack.com/tools/cloud-services-hub/aws-x-ray)**: AWS SAM enables X-Ray tracing for Lambda functions, API Gateway REST APIs, and Step Functions workflows through resource tracing settings. For generated Lambda execution roles, it adds the permissions needed to publish trace data.

## What is AWS Serverless Application Model (AWS SAM)

The AWS Serverless Application Model, known as AWS SAM, serves as a comprehensive framework designed for the development and deployment of serverless applications. It is specifically tailored for use within the AWS ecosystem, streamlining the process to build scalable, high-performing services without having to manage servers. The serverless approach significantly reduces the operational burden on developers, allowing them to focus on writing code that adds direct value to their business or project, rather than concerning themselves with the underlying infrastructure.

AWS SAM extends AWS CloudFormation, providing a simplified syntax to express functions, APIs, databases, and event source mappings. With this model, the definition of an application's infrastructure becomes as straightforward as describing its components in a simple configuration file. This SAM template, typically written in YAML, acts as a blueprint for AWS to understand how to provision and configure the necessary resources for the serverless application to run. An essential part of AWS SAM is the SAM CLI (Command Line Interface), a tool that facilitates local development and testing of serverless applications. It empowers developers to run their applications in an environment that closely mimics AWS, offering a more accurate development experience.

A SAM template can combine standard CloudFormation syntax with SAM's shorthand syntax in the same template.

Through the SAM CLI, developers can invoke functions locally, start a local API Gateway from a SAM template, validate SAM templates, and even generate sample payloads for various event sources. This local development capability accelerates the feedback loop, enabling rapid iteration and testing. Integration with other AWS services is a cornerstone of the SAM framework, ensuring that serverless applications can easily leverage the rich ecosystem of AWS offerings. This includes services like Amazon DynamoDB for databases, Amazon API Gateway for creating RESTful APIs, and Amazon EventBridge for event-driven architectures, among others. Not only does this facilitate the development of complex, distributed applications but it also ensures that these applications can scale automatically and remain highly available without direct intervention from the developer.

Security is another critical aspect addressed by AWS SAM. It seamlessly integrates with AWS Identity and Access Management (IAM), allowing developers to define granular access control to their serverless applications. By specifying IAM roles and policies directly within the SAM template, developers can enforce stringent security measures, ensuring that the application adheres to the principle of least privilege.

In conclusion, AWS SAM represents an evolutionary leap in the realm of serverless application development. By abstracting away much of the complexity associated with infrastructure management, it allows developers to harness the full potential of serverless computing. Through its simplified syntax, local development capabilities, deep integration with AWS services, and robust security features, AWS SAM provides a formidable framework for building, deploying, and managing serverless applications at scale.

## AWS Serverless Application Model (AWS SAM) exam questions

Real practice exam questions on AWS Serverless Application Model (AWS SAM), with the correct answer and its explanation.

### Question 1 (DEA-C01)

**Question:**

A data engineer uses AWS SAM to deploy a pipeline into separate development and production stacks. Each stack creates an Amazon DynamoDB table with the logical ID TransformedRecords and an AWS::Serverless::Function that writes transformed records by calling PutItem. The table's physical name is generated during deployment. The function reads the target table name from the TABLE_NAME environment variable.

SAM generates the function's execution role, which currently has only logging permissions. The engineer must configure each function to write to its own stack's table, grant only the required DynamoDB action, and avoid hardcoded table names or ARNs.

Which configuration meets these requirements?

**Correct answer:** Set TABLE_NAME to !Ref TransformedRecords. In the function's Policies property, add an IAM statement allowing dynamodb:PutItem with Resource set to !GetAtt TransformedRecords.Arn.

**Explanation:** For a DynamoDB table, Ref returns the table name, and GetAtt with Arn returns its ARN. The environment variable therefore identifies the correct stack-specific table, while the policy grants the function's generated execution role only PutItem access to that table.

### Question 2 (DOP-C02)

**Question:**

A company uses AWS CodeBuild and the AWS SAM CLI to generate artifacts for a serverless application. Several Python Lambda functions use a shared AWS::Serverless::LayerVersion resource with the logical ID NativeToolsLayer and ContentUri set to tools/. The functions invoke a compiled helper at /opt/bin/report-helper.

The tools/ directory contains C++ source code and a Makefile with an existing compilation recipe, but it does not contain the compiled executable. The CodeBuild environment has a compiler and libraries compatible with the functions' Lambda runtime and x86_64 architecture. The functions' Python dependencies already build successfully.

A DevOps engineer must integrate compilation of the helper into sam build so that the generated layer artifact contains the executable at the required location. The engineer must use SAM's custom build mechanism without adding a separate compilation step to the buildspec or committing compiled files to the repository.

Which configuration meets these requirements?

**Correct answer:** Add Metadata with BuildMethod: makefile to NativeToolsLayer. In tools/Makefile, define build-NativeToolsLayer to run the compilation recipe and copy the executable to $(ARTIFACTS_DIR)/bin/report-helper.

**Explanation:** SAM supports custom Makefile builds for layers. BuildMethod: makefile selects this mechanism, and SAM invokes the build target named build- followed by the resource's logical ID. The recipe must place its output in ARTIFACTS_DIR. Lambda extracts layer contents under /opt, so bin/report-helper in the layer becomes /opt/bin/report-helper.

### Question 3 (DVA-C02)

**Question:**

A developer maintains a serverless application whose template defines several API Gateway REST API routes and their Lambda function integrations. An existing HTTP test suite sends requests to a configurable base URL and checks route selection, query string handling, response headers, and response bodies. The functions do not call external services.

Before deploying changes, the developer must run the test suite unchanged against the local application without creating AWS resources. Docker and the required development tools are installed.

Which approach meets these requirements?

**Correct answer:** Run `sam build`, then run `sam local start-api`. Configure the test suite's base URL to use the local HTTP endpoint and execute the tests.

**Explanation:** `sam local start-api` uses the template's API definitions to expose local HTTP routes and invoke the associated Lambda functions in Docker containers. The existing HTTP tests can exercise route selection, request handling, and responses without deploying AWS resources. This does not replace subsequent testing of deployed service behavior.

## Practice AWS Serverless Application Model (AWS SAM) in a full exam

Questions on AWS Serverless Application Model (AWS SAM) in each practice exam, with every answer option and an explanation for each:

- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 9 questions
- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 8 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 6 questions

## Learn AWS Serverless Application Model (AWS SAM) in lessons

4 short lessons on AWS Serverless Application Model (AWS SAM) in 2 certification courses.

- DEA-C01: AWS SAM: packaging and deploying serverless applications (Premium), https://app.blowstack.com/lessons/aws-sam-packaging-and-deploying-serverless-applications-dea-c01
- DOP-C02: AWS SAM: composing and deploying application templates (Premium), https://app.blowstack.com/lessons/aws-sam-composing-and-deploying-application-templates-dop-c02
- DEA-C01: AWS SAM and AWS CloudFormation: serverless shorthand versus general infrastructure templates (Premium), https://app.blowstack.com/lessons/aws-sam-and-aws-cloudformation-serverless-shorthand-versus-general-infrastructure-templates-dea-c01
- DOP-C02: AWS SAM and AWS CloudFormation: abstraction and provisioning (Premium), https://app.blowstack.com/lessons/aws-sam-and-aws-cloudformation-abstraction-and-provisioning-dop-c02
