Skip to content

(ecs): enableDeploymentAlarms does not actually add additional alarms #36308

@vito-laurenza-zocdoc

Description

@vito-laurenza-zocdoc

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

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions