(aws-lambda): `Alias.scaleOnSchedule()` doesn't make clear which `Schedule` to use
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
## Ambiguous `Schedule` import causing inconsistent behavior
There seems to be an issue with the `Schedule` import used in `scaleOnSchedule`. Depending on which AWS CDK library the `Schedule` class is imported from, the code exhibits different behavior:
- `import { Schedule } from "aws-cdk-lib/aws-applicationautoscaling"`: **Works**
- `import { Schedule } from "aws-cdk-lib/aws-events"`: **Works**
- `import { Schedule } from "aws-cdk-lib/aws-autoscaling"`: **Fails**
### Expected Behavior
The `Schedule` import should be unambiguous, and the code should function consistently regardless of which AWS CDK library it is imported from.
### Current Behavior
You may import the wrong `Schedule` without noticing until deployment.
### Reproduction Steps
Use the following code snippet:
```ts
const scalableFunction = new NodejsFunction(this, "ScalableFunction", {
functionName: "scalable-function",
entry: join(__dirname, "..", "functions", "scalable", "index.ts"),
runtime: Runtime.NODEJS_20_X,
architecture: Architecture.ARM_64,
memorySize: 1024,
timeout: Duration.minutes(5),
loggingFormat: LoggingFormat.JSON,
});
const scalableFunctionAlias = new Alias(this, "ScalableFunctionAlias", {
aliasName: "live",
version: scalableFunction.currentVersion,
});
scalableFunctionAlias
.addAutoScaling({
minCapacity: 1,
maxCapacity: 10,
})
.scaleOnSchedule("ScaleUpInMorning", {
schedule: Schedule.cron({ hour: "3", minute: "30" }), // Change the import to test different scenarios
minCapacity: 5,
});
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.145.0
### Framework Version
_No response_
### Node.js Version
20.13.1
### OS
Ubuntu 22.04.3 LTS
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start with the Alias.scaleOnSchedule API and run the TypeScript reproduction using Schedule from aws-applicationautoscaling, aws-events, and aws-autoscaling. Done means the accepted Schedule is unambiguous and the same cron configuration behaves consistently regardless of the imported class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100