我准备了一个弹性的beanstalk cloudformation模板。
Resources:
BeanStalkApplciation:
Type: 'AWS::ElasticBeanstalk::Application'
Condition: conCreateBeanStalkApplication
Properties:
ApplicationName: !Ref BeanStalkApplciationName
Description: PBKMSService Beanstalk applciation
BeanstalkEnvironmet:
Type: 'AWS::ElasticBeanstalk::Environment'
Properties:
TemplateName: !If
- conDontUseConfigTemplate
- !Ref 'AWS::NoValue'
- !Ref BeanStalkConfigTemplateName
EnvironmentName: !Join
- '-'
- - !Ref BeanStalkApplciationName
- !Ref BeanStalkEnvironment
Description: Service 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: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: BreachDuration
Value: 5
- Namespace: 'aws:autoscaling:trigger'
OptionName: UpperThreshold
Value: 100
- Namespace: 'aws:autoscaling:trigger'
OptionName: UpperBreachScaleIncrement
Value: 1
- 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: Subnets
Value: !Join
- ','
- !Ref BeanStalkApplcitionSubnets
- Namespace: 'aws:ec2:vpc'
OptionName: ELBSubnets
Value: !Join
- ','
- !Ref BeanStalkELBSubnets
- Namespace: 'aws:ec2:vpc'
OptionName: AssociatePublicIpAddress
Value: !Ref AssignPublicIPToEC2
- Namespace: 'aws:elb:loadbalancer'
OptionName: CrossZone
Value: 'true'
- Namespace: 'aws:ec2:vpc'
OptionName: ELBScheme
Value: !If
- conIsInternalApplcation
- 'internal'
- !Ref 'AWS::NoValue'
- Namespace: 'aws:elb:listener:443'
OptionName: ListenerEnabled
Value: !If
- conIsInternalApplcation
- false
- true
- Namespace: 'aws:elb:listener:443'
OptionName: SSLCertificateId
Value: !If
- conIsInternalApplcation
- !Ref 'AWS::NoValue'
- !Ref SSLCertificateARN
- Namespace: 'aws:elb:listener:443'
OptionName: ListenerProtocol
Value: HTTPS
- Namespace: 'aws:elb:listener:443'
OptionName: InstancePort
Value: '80'
- Namespace: 'aws:elb:listener:443'
OptionName: InstanceProtocol
Value: HTTP
- Namespace: 'aws:elb:listener'
OptionName: ListenerEnabled
Value: !If
- conIsInternalApplcation
- true
- false
- Namespace: 'aws:elb:listener:80'
OptionName: ListenerEnabled
Value: !If
- conIsInternalApplcation
- true
- false
- Namespace: 'aws:elb:listener:80'
OptionName: ListenerProtocol
Value: HTTP
- Namespace: 'aws:elb:listener:80'
OptionName: InstancePort
Value: '80'
- Namespace: 'aws:elb:listener:80'
OptionName: InstanceProtocol
Value: HTTP
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_APP_NAME
Value: !Ref envAppdynamicsApplciationName
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: MAGENT_APPD_APP_NAME
Value: !Ref envAppdynamicsMachineAgentApplciationName
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_TIER_NAME
Value: !Ref envAppdynamicsTierName
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_ACCT_NAME
Value: !Ref envAppdynamicsAgentAccountName
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_CONT_HOST
Value: !Ref envAppdynamicsControllerHostName
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_CONT_PORT
Value: !Ref envAppdynamicsControllerPort
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_CONT_SSL_ENABLED
Value: !Ref envAppdynamicsControllerSslEnabled
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: APPD_ACCESS_KEY
Value: !Ref envAppdynamicsAgentAccountAccessKey
- Namespace: 'aws:elasticbeanstalk:application:environment'
OptionName: SPLUNK_SERVER_HOST
Value: !Ref envSplunkServerHost
我想为它添加监控功能。我没有找到任何关于相同的参考/例子。有人可以帮助我。
创建弹性beanstalk后,您将进入监控状态。我想使用cloudformation添加几个图表。以下是监控UI的屏幕截图。
我已经提到了这篇文章 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aeb-metricscollected.html
但又不清楚。如何获取beanstalk资源的instanceid? 我们甚至可以使用cloudformation做到这一点吗?请帮忙