- Newest
- Most votes
- Most comments
To "clear up" the confusion: I think the reason adding Provisioned Concurrency (PC) doesn't help you right now is that PC is only effective if the invocation path actually hits the Alias/Version where it is configured.
Here is a breakdown of exactly what you need to do and why:
1. The "Why": Current State vs. Goal
- Current: Your DynamoDB Stream is mapped to the Lambda Function (which defaults to the
$LATESTversion). Provisioned Concurrency cannot be applied to$LATEST. Even if you put PC on an Alias, your Stream isn't "looking" at that Alias, so it encounters cold starts/throttling on$LATEST. - Goal: You must point the Event Source Mapping (ESM) to the Alias ARN. Only then will the Stream use the "warm" capacity you’ve provisioned.
2. The Fix (CDK)
You must move the addEventSourceMapping from the function object to the alias object:
// From this:
// ddbStreamLambda.addEventSourceMapping(...)
// To this:
ddbStreamLambdaAlias.addEventSourceMapping(...)
3. Deployment & Data Loss (The "One-Deploy" Concern)
- No Data Loss: DynamoDB Streams retain data for 24 hours. When you update the ESM via CDK, AWS replaces the mapping. During the few seconds of transition, events simply stay in the stream.
- Checkpointing: Once the new mapping to the Alias is active, the Lambda service resumes processing from the last successfully processed sequence number. You will see a slight spike in
GetRecords.IteratorAgeMilliseconds, which will normalize once the Lambda catches up. - Throttling: Once the mapping points to the Alias, the "Throttles" during deployment will disappear because the Alias will point to a Version with active Provisioned Concurrency, ensuring "warm" containers are ready immediately.
In short:
- Change
addEventSourceMappingto target the Alias. - Apply
provisionedConcurrencyto the Alias. - Deploy.
Note: When you switch the ESM to the Alias, the CDK usually handles the IAM policy updates automatically, but ensure your Lambda execution role still has lambda:InvokeFunction permissions for the Alias ARN (e.g., ...:function:my-func:my-alias).
Let me address your questions about Lambda aliases and event source mappings:
Question 1: Is the alias being invoked?
No, the alias is not being invoked in your current setup. When you configure the event source mapping directly on the Lambda function (using ddbStreamLambda.addEventSourceMapping), the DynamoDB stream invokes the function directly, not through the alias. This is why you see metrics and triggers under the Lambda function page but not under the alias tab.
To have the alias invoked, you need to specify the alias ARN in the event source mapping configuration. Event sources like DynamoDB Streams maintain a mapping that identifies which function to invoke when events occur. If you specify a Lambda function alias in the mapping configuration, the events will be routed through that alias.
Question 2: Where to add provisioned concurrency?
You should add provisioned concurrency to the alias, not directly to the Lambda function. Provisioned concurrency is configured at the alias or version level, not on the $LATEST version or the base function. This allows you to allocate specific concurrency capacity to particular versions of your function through aliases, which is especially useful for managing traffic during deployments.
Question 3: Will moving the event source mapping cause event loss?
Moving the event source mapping from the function to the alias in a single CDK deployment could potentially cause a brief interruption. During the deployment, CDK will likely delete the old event source mapping and create a new one pointing to the alias. DynamoDB Streams maintains checkpoint information in the event source mapping, so recreating it may cause the stream to restart processing from a different position (typically LATEST or TRIM_HORIZON depending on your configuration). To minimize risk, consider:
- Ensuring your Lambda function is idempotent to handle potential duplicate processing
- Monitoring the deployment closely
- Consider a blue-green deployment approach if zero data loss is critical
The benefit of using aliases in your event source mapping is that future version updates won't require updating the mapping configuration - you can simply update which version the alias points to.
Sources
Using Lambda aliases in event sources and permissions policies - AWS Lambda
aws-cdk-lib.aws_lambda module · AWS CDK
Relevant content
- asked 2 years ago
- asked 2 years ago

If the alias is not being invoked, then why add provisioned concurrency to the alias will help with the lambda throttle?
From your question, I reckon you intention is to use the alias. Therefore, you will need to update to use the alias as per the suggestion from "Question 1: Is the alias being invoked?".