A developer is deploying a serverless application using the AWS Serverless Application Model (SAM). The application includes an Amazon API Gateway HTTP API and several AWS Lambda functions. The developer wants to implement a canary deployment for the API Gateway stage so that 10% of traffic is shifted to the new version for 30 minutes before the remaining 90% is shifted. Which SAM resource attribute should the developer configure on the API Gateway resource?
Trap 1: AutoPublishAlias
AutoPublishAlias is a property within the AWS Serverless Application Model (SAM) that automatically creates a new Lambda function version and updates a specified alias to point to this new version upon deployment. While crucial for managing Lambda function versions and enabling alias-based invocation, it solely operates at the Lambda function level. It does not provide any mechanism for gradual traffic shifting or canary deployments for an associated API Gateway stage, which requires specific API Gateway deployment configurations.
Trap 2: ProvisionedConcurrencyConfig
ProvisionedConcurrencyConfig is used to pre-initialize a specified number of execution environments for a Lambda function, ensuring low latency for invocations by avoiding cold starts. While vital for performance-sensitive applications, especially those invoked via API Gateway, its sole purpose is to manage Lambda function readiness. It has no direct control over how API Gateway routes traffic between different versions of an API or its underlying Lambda functions during a deployment.
Trap 3: EventInvokeConfig
EventInvokeConfig defines the asynchronous invocation behavior for a Lambda function, specifically controlling retry attempts, maximum event age, and dead-letter queue (DLQ) destinations for failed invocations. This configuration is relevant for event sources like S3, SQS, or direct asynchronous API calls to Lambda. However, it pertains exclusively to the asynchronous processing characteristics of a Lambda function and does not influence the synchronous request routing or traffic shifting mechanisms of an API Gateway stage.
- A
AutoPublishAlias
Why wrong: AutoPublishAlias is a property within the AWS Serverless Application Model (SAM) that automatically creates a new Lambda function version and updates a specified alias to point to this new version upon deployment. While crucial for managing Lambda function versions and enabling alias-based invocation, it solely operates at the Lambda function level. It does not provide any mechanism for gradual traffic shifting or canary deployments for an associated API Gateway stage, which requires specific API Gateway deployment configurations.
- B
DeploymentPreference
The DeploymentPreference property in AWS SAM, when configured with a Canary type, directly enables gradual traffic shifting for an API Gateway stage. This setting allows a percentage of incoming API requests to be routed to the newly deployed version of the Lambda function (or other backend), while the majority continues to serve the stable version. This controlled rollout minimizes risk by allowing monitoring of the new version's performance and error rates before a full cutover.
- C
ProvisionedConcurrencyConfig
Why wrong: ProvisionedConcurrencyConfig is used to pre-initialize a specified number of execution environments for a Lambda function, ensuring low latency for invocations by avoiding cold starts. While vital for performance-sensitive applications, especially those invoked via API Gateway, its sole purpose is to manage Lambda function readiness. It has no direct control over how API Gateway routes traffic between different versions of an API or its underlying Lambda functions during a deployment.
- D
EventInvokeConfig
Why wrong: EventInvokeConfig defines the asynchronous invocation behavior for a Lambda function, specifically controlling retry attempts, maximum event age, and dead-letter queue (DLQ) destinations for failed invocations. This configuration is relevant for event sources like S3, SQS, or direct asynchronous API calls to Lambda. However, it pertains exclusively to the asynchronous processing characteristics of a Lambda function and does not influence the synchronous request routing or traffic shifting mechanisms of an API Gateway stage.