如何在Alarm中引用Elastic beanstalk资源

时间:2018-06-13 10:16:59

标签: amazon-web-services elastic-beanstalk amazon-cloudformation

下面是我用来创建弹性豆柄的代码片段。我删除了部分代码,但是我运行了这段代码并创建了beanstalk。

BeanStalkApplciation:
    Type: 'AWS::ElasticBeanstalk::Application'
    Condition: conCreateBeanStalkApplication
    Properties:
      ApplicationName: !Ref BeanStalkApplciationName
      Description: PBKMSService Beanstalk applciation
  BeanstalkEnvironmet:
    Type: 'AWS::ElasticBeanstalk::Environment'
    Properties:
      EnvironmentName: BeanStalkEnvironment
      Description: Beanstalk Environment
      ApplicationName: !Ref BeanStalkApplciationName
      SolutionStackName: !Ref BeanStalkSolutionStackName
      Tier:
        Name: WebServer
        Type: Standard
      OptionSettings:
        - Namespace: 'aws:elasticbeanstalk:environment'
          OptionName: ServiceRole
          Value: aws-elasticbeanstalk-service-role
        - Namespace: 'aws:elasticbeanstalk:environment'
          OptionName: ServiceRole
          Value: aws-elasticbeanstalk-service-role
        - Namespace: 'aws:autoscaling:asg' 
          ResourceName: beanstalkautoscalinggroup
        - Namespace: 'aws:autoscaling:launchconfiguration'
          OptionName: IamInstanceProfile
          Value: aws-elasticbeanstalk-ec2-role
        - Namespace: 'aws:autoscaling:launchconfiguration'
          OptionName: InstanceType
          Value: !Ref EC2InstanceType
        - Namespace: 'aws:autoscaling:asg'
          OptionName: Availability Zones
          Value: Any 2
        - Namespace: 'aws:autoscaling:asg'
          OptionName: MinSize
          Value: !Ref AutoscalingMinSize
        - Namespace: 'aws:autoscaling:asg'
          OptionName: MaxSize
          Value: !Ref AutoscalingMaxSize
        - Namespace: 'aws:autoscaling:trigger'
          OptionName: MeasureName
          Value: RequestCount
        - Namespace: 'aws:autoscaling:trigger'
          OptionName: Statistic
          Value: Sum
        - Namespace: 'aws:autoscaling:trigger'
          OptionName: Unit
          Value: Count/Second
        - Namespace: 'aws:autoscaling:trigger'
          OptionName: Period
          Value: 5
        - Namespace: 'aws:autoscaling:trigger'
          OptionName: LowerThreshold
          Value: 50
        - Namespace: 'aws:autoscaling:trigger'
          OptionName: LowerBreachScaleIncrement
          Value: -1
        - Namespace: 'aws:autoscaling:updatepolicy:rollingupdate'
          OptionName: RollingUpdateEnabled
          Value: 'true'
        - Namespace: 'aws:autoscaling:updatepolicy:rollingupdate'
          OptionName: RollingUpdateType
          Value: Health
        - Namespace: 'aws:elasticbeanstalk:customoption'
          OptionName: EBLogGroup
          Value: !Ref CloudwatchLogGroup
        - Namespace: 'aws:autoscaling:launchconfiguration'
          OptionName: SecurityGroups
          Value: !Ref EC2SecGroupForBeanStalk
        - Namespace: 'aws:elb:loadbalancer'
          OptionName: SecurityGroups
          Value: !Ref ELBSecGroupForBeanStalk
        - Namespace: 'aws:autoscaling:launchconfiguration'
          OptionName: EC2KeyName
          Value: !Ref KeyPairForEc2Instances
        - Namespace: 'aws:ec2:vpc'
          OptionName: VPCId
          Value: !Ref VpcId
        - Namespace: 'aws:ec2:vpc'
          OptionName: AssociatePublicIpAddress
          Value: !Ref AssignPublicIPToEC2
        - Namespace: 'aws:elb:loadbalancer'
          OptionName: CrossZone
          Value: 'true'

现在我想为其添加不同类型的警报,我必须在尺寸中引用负载平衡器和自动缩放组名称。我面临的挑战是我不知道如何获得资源部门或参考它。怎么做。我想为eleastic beanstalk添加警报。

CPUAlarmHigh:
    Type: AWS::CloudWatch::Alarm
 Properties:
      Namespace: AWS/EC2
      MetricName: CPUUtilization
      Dimensions:
      - Name: AutoScalingGroupName
        Value: **How can I refer created autoscaling group of beanstalk**
      ComparisonOperator: GreaterThanThreshold
      AlarmActions: !Ref AlarmTopic
      InsufficientDataActions: !Ref AlarmTopic

0 个答案:

没有答案