aws-cdk-lib/aws-lambda: Incorrect order of operations when changing both Python version and architecture
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When changing both Python runtime version and architecture, the order of operations prevents the operation from succeeding. For example, if a deployed Lambda is configured for Python 3.9 and ARM64, changing to to Python 3.7 and X86_64 fails during deploy.
### Expected Behavior
Changing the runtime and architecture should succeed when deploying.
### Current Behavior
During `cdk deploy`, the Lambda function update fails with the following error message:
`ExampleStack | 0/3 | 4:44:26 PM | UPDATE_FAILED | AWS::Lambda::Function | MyFunction (MyFunction3BAA72D1) Resource handler returned message: "Runtime python3.7 does not support the following architectures [arm64]. Please select different architectures from [x86_64] or select a different runtime. (Service: Lambda, Status Code: 400, Request ID: example5-9228-4208-b024-0dd9e9a9b03a)" (RequestToken: example1-f7ef-5669-2ab1-5ed0b6c59b30, HandlerErrorCode: InvalidRequest) `
### Reproduction Steps
Given the following already-deployed code:
```
import * as lambda from 'aws-cdk-lib/aws-lambda';
const myFunction = new lambda.Function(this, 'MyFunction', {
...
runtime: lambda.Runtime.PYTHON_3_9,
architecture: lambda.Architecture.ARM64,
...
}
```
Change the runtime and architecture configuration as follows:
```
runtime: lambda.Runtime.PYTHON_3_7,
architecture: lambda.Architecture.X86_64,
```
Running `cdk diff` at this point will show that both runtime and architecture will be updated. Performing `cdk deploy` causes an error because the runtime is changed before the architecture, and the 3.7 runtime does not support ARM64.
### Possible Solution
Change the order of operations to update the architecture before the runtime.
### Additional Information/Context
_No response_
### CDK CLI Version
2.92.0 (build bf62e55)
### Framework Version
_No response_
### Node.js Version
v18.17.1
### OS
Windows 10
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start in aws-cdk-lib/aws-lambda and trace the resource update emitted for runtime and architecture; use cdk diff and cdk deploy with the supplied Python 3.9/ARM64 to Python 3.7/X86_64 transition. Done means the architecture change is applied before the incompatible runtime change and deployment succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100