(ecs): enableDeploymentAlarms does not actually add additional alarms
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
`BaseService.enableDeploymentAlarms()` doesn't actually add new alarms to the deployment configuration.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
`BaseService.enableDeploymentAlarms()` should add the alarms to the deployment configuration
### Current Behavior
Any alarms passed to `BaseService.enableDeploymentAlarms()` are silently ignored.
### Reproduction Steps
```typescript
describe('enableDeploymentAlarms', () => {
test('enableDeploymentAlarms will concat alarms in the deployment configuration when called more than once', () => {
// GIVEN
const vpc = new ec2.Vpc(stack, 'Vpc');
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');
taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
});
const expectedAlarmNames = ['alarm1', 'alarm2', 'alarm3'];
// WHEN
const service = new ecs.FargateService(stack, 'FargateService', {
cluster,
taskDefinition,
minHealthyPercent: 100,
maxHealthyPercent: 200,
deploymentAlarms: { alarmNames: ['alarm1'] },
});
service.enableDeploymentAlarms(['alarm2']);
service.enableDeploymentAlarms(['alarm3']);
// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', {
DeploymentConfiguration: {
Alarms: {
AlarmNames: expectedAlarmNames,
Enable: true,
Rollback: true,
},
},
});
});
});
});
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
main
### AWS CDK CLI version
main
### Node.js Version
v20.19.5
### OS
Linux 2dc632a883eb 6.12.54-linuxkit #1 SMP Tue Nov 4 21:21:47 UTC 2025 aarch64 GNU/Linux
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start at BaseService.enableDeploymentAlarms() and use the provided ecs test as the reproduction. Check the synthesized AWS::ECS::Service DeploymentConfiguration after calling the method more than once. Done means alarm1, alarm2, and alarm3 all appear in AlarmNames with Enable and Rollback still true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100