getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.

Home Page:http://docs.getmoto.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

describe_scaling_policies doesn't return the associated CW alarms

v-rosa opened this issue · comments

  • Guidance on how to reproduce the issue.

Create an autoscaling policy of type TargetTrackingScaling and then describe it.

resourceId="service/cluster-test/service"

aas_client.put_scaling_policy(
        PolicyName=policy_name,
        PolicyType='TargetTrackingScaling',
        ResourceId=resource_id,
        ScalableDimension='ecs:service:DesiredCount',
        ServiceNamespace='ecs',
        TargetTrackingScalingPolicyConfiguration={
            'PredefinedMetricSpecification': {
                'PredefinedMetricType': policy["predefined_metric"],
            },
            'ScaleInCooldown': policy["scale_in_cooldown"],
            'ScaleOutCooldown': policy["scale_out_cooldown"],
            'TargetValue': policy["target"],
        },
)

result = aas_client.describe_scaling_policies(
    ServiceNamespace='ecs',
    ResourceId=resource_id
)

print(result['ScalingPolicies'])
### [{'PolicyARN': 'arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:55a710b9-8533-44fe-b6c3-8ee75bf9e6e7:resource/ecs/service/test-internal-pet/f545b2ca-6eb6-4833-a1f7-a64494e60e8c:policyName/f545b2ca-6eb6-4833-a1f7-a64494e60e8c-target-tracking', 'PolicyName': 'f545b2ca-6eb6-4833-a1f7-a64494e60e8c-target-tracking', 'ServiceNamespace': 'ecs', 'ResourceId': 'service/test-internal-pet/f545b2ca-6eb6-4833-a1f7-a64494e60e8c', 'ScalableDimension': 'ecs:service:DesiredCount', 'PolicyType': 'TargetTrackingScaling', 'TargetTrackingScalingPolicyConfiguration': {'TargetValue': 70, 'PredefinedMetricSpecification': {'PredefinedMetricType': 'ECSServiceAverageCPUUtilization'}, 'ScaleOutCooldown': 100, 'ScaleInCooldown': 100}, 'CreationTime': datetime.datetime(2024, 3, 27, 15, 50, 7, 726198, tzinfo=tzlocal())}]
  • Tell us what you expected to happen.

Return the list of CW Alarms associated with the scaling policy as per documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/application-autoscaling/client/describe_scaling_policies.html

  • Tell us what actually happens.
    Returns a response object without the associated alarms, e.g.:
[{'PolicyARN': 'arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:55a710b9-8533-44fe-b6c3-8ee75bf9e6e7:resource/ecs/service/test-internal-pet/f545b2ca-6eb6-4833-a1f7-a64494e60e8c:policyName/f545b2ca-6eb6-4833-a1f7-a64494e60e8c-target-tracking', 'PolicyName': 'f545b2ca-6eb6-4833-a1f7-a64494e60e8c-target-tracking', 'ServiceNamespace': 'ecs', 'ResourceId': 'service/test-internal-pet/f545b2ca-6eb6-4833-a1f7-a64494e60e8c', 'ScalableDimension': 'ecs:service:DesiredCount', 'PolicyType': 'TargetTrackingScaling', 'TargetTrackingScalingPolicyConfiguration': {'TargetValue': 70, 'PredefinedMetricSpecification': {'PredefinedMetricType': 'ECSServiceAverageCPUUtilization'}, 'ScaleOutCooldown': 100, 'ScaleInCooldown': 100}, 'CreationTime': datetime.datetime(2024, 3, 27, 15, 50, 7, 726198, tzinfo=tzlocal())}]
  • Tell us what version of Moto you're using, and how you installed it

Moto server v5.0.3

python3 -m venv .venv
source .venv/bin/activate
pip3 install --upgrade pip
pip3 install --upgrade setuptools
pip3 install -r requirements.txt

Hi @v-rosa, thanks for raising this - marking it as an enhancement to create these alarms.