Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudwatch alarms: how to add alarm dependency? #1213

Closed
clareliguori opened this issue Nov 19, 2018 · 2 comments · Fixed by #1226
Closed

cloudwatch alarms: how to add alarm dependency? #1213

clareliguori opened this issue Nov 19, 2018 · 2 comments · Fixed by #1226
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-elasticloadbalancing Related to Amazon Elastic Load Balancing bug This issue is a bug.

Comments

@clareliguori
Copy link
Member

Version: 0.18.0

I'm running into a dependency issue creating an alarm: the alarm dimensions indirectly refer to a target group and load balancer that have not yet been created during stack creation. How do I add a dependency on these objects? There doesn't seem to be a way to add the equivalent of "DependsOn" to a construct.

Code:

   new Alarm(this, 'TargetGroupUnhealthyHosts', {
      metric: service.targetGroup.metricUnhealthyHostCount(),
      threshold: 1,
      evaluationPeriods: 2,
    });

Error:

Template error: Fn::Select  cannot select nonexistent value at index 0

Generated snippet:

      Dimensions:
        - Name: TargetGroup
          Value:
            'Fn::GetAtt':
              - ServiceLBPublicListenerECSGroup0CC8688C
              - TargetGroupFullName
        - Name: LoadBalancer
          Value:
            'Fn::Join':
              - ''
              - - 'Fn::Select':
                    - 1
                    - 'Fn::Split':
                        - /
                        - 'Fn::Select':
                            - 0
                            - 'Fn::GetAtt':
                                - ServiceLBPublicListenerECSGroup0CC8688C
                                - LoadBalancerArns
                - /
                - 'Fn::Select':
                    - 2
                    - 'Fn::Split':
                        - /
                        - 'Fn::Select':
                            - 0
                            - 'Fn::GetAtt':
                                - ServiceLBPublicListenerECSGroup0CC8688C
                                - LoadBalancerArns
                - /
                - 'Fn::Select':
                    - 3
                    - 'Fn::Split':
                        - /
                        - 'Fn::Select':
                            - 0
                            - 'Fn::GetAtt':
                                - ServiceLBPublicListenerECSGroup0CC8688C
                                - LoadBalancerArns
@rix0rrr rix0rrr added bug This issue is a bug. @aws-cdk/aws-elasticloadbalancing Related to Amazon Elastic Load Balancing @aws-cdk/aws-ecs Related to Amazon Elastic Container labels Nov 20, 2018
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 20, 2018

It's again that association problem. Grrr.

@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 20, 2018

Ye gods this is a tricky one, too.

rix0rrr added a commit that referenced this issue Nov 21, 2018
TargetGroup metrics used to use ${TargetGroup.LoadBalancerArns} to find
the load balancer's full name, but that introduces a deployment-time
ordering dependency on the creation of the Listener object.

Instead, use the Listener ARN to get the load balancer name. We
now have an ordering requirement in the CDK code but that can be
detected early and solved by the user.

Fixes #1213.
rix0rrr added a commit that referenced this issue Nov 21, 2018
TargetGroup metrics used to use ${TargetGroup.LoadBalancerArns} to find
the load balancer's full name, but that introduces a deployment-time
ordering dependency on the creation of the Listener object.

Instead, use the Listener ARN to get the load balancer name. We
now have an ordering requirement in the CDK code but that can be
detected early and solved by the user.

Fixes #1213.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-elasticloadbalancing Related to Amazon Elastic Load Balancing bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants