iann0036 / AWSConsoleRecorder

Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.
MIT License
1.43k stars 86 forks source link

CloudWatch Alarm generation isnt properly defining dimensions. #18

Closed jplewes closed 5 years ago

jplewes commented 5 years ago

Describe the bug CloudWatch Alarm recording is incorrectly defining the dimensions for the metric being captured when the metric has multiple dimensions. The code being generated does have the correct count of dimensions, but all appear to be defined as the same one.

Related Mapping cloudwatch putMetricAlarm

Related Language Affects all generated languages

To Reproduce Steps to reproduce the behavior:

  1. In the AWS console navigate to CloudWatch -> Alarms
  2. Click "Create Alarm"
  3. Choose a Metric that has multiple dimensions, e.g. ApplicationELB: Per AppELB, per AZ, per TG Metrics
  4. Enter the relevant Alarm criteria.. name, description, actions etc.
  5. Save the alarm

Expected behavior The generated code should have multiple unique dimensions defined, one for each dimension based on the metric chosen for the alarm.

Screenshots CloudFormation example:

cloudwatch6ef73f1:
    Type: "AWS::CloudWatch::Alarm"
    Properties:
        Dimensions: 
          - 
            Name: "TargetGroup"
            Value: "targetgroup/XXXXX-XXXXX-XXXXX/aaaabbbbccccdddd"
          - 
            Name: "TargetGroup"
            Value: "targetgroup/XXXXX-XXXXX-XXXXX/aaaabbbbccccdddd"
          - 
            Name: "TargetGroup"
            Value: "targetgroup/XXXXX-XXXXX-XXXXX/aaaabbbbccccdddd"
        OKActions: []

Additional context It appears that the code isn't iterating the dimensions and simply using the same dimension each time for the qty of dimensions defined.

iann0036 commented 5 years ago

Hey Jeff,

Thanks for raising, I've got the fix in 0.3.5+ which will be available from the stores in an hour or so.

Appreciate the help!